> ## Documentation Index
> Fetch the complete documentation index at: https://wordsmithai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Power Automate

> Hand legal work to a Wordsmith agent from a Power Automate flow, such as a Microsoft Forms submission.

The Wordsmith connector for Power Automate lets any flow send work to Wordsmith and use the answer in later steps. A flow can start from any Microsoft trigger: a Microsoft Forms response, a new SharePoint list item, an Outlook email, a Teams message or an approval. The same connector works in Logic Apps and Copilot Studio.

> [!NOTE]
>
> The connector is not yet in Microsoft's connector gallery. Until it is, an administrator of your Power Platform environment imports it as a custom connector. See [Import the connector](#import-the-connector).

## Actions

| Action | What it does |
| - | - |
| **Ask an agent and wait for the answer** | Asks an agent a question, with optional files, and waits until the agent answers. Returns the answer, the decline reason if the agent declined, files the agent created, and a link to the conversation. |
| **Create a task** | Creates a task. Assign it to an agent to have the agent start on it, or to a person. Returns the task and its link. |
| **Upload a file** | Stores a file of up to 3 MB in your private Wordsmith space and returns its file ID, for a question or a task. |
| **Attach files to a task** | Attaches uploaded files to a task. |
| **Get a question** | Returns a question's status and answer. |
| **Get a task** | Returns a task's status, assignees and files. |
| **List agents** | Lists the agents you can ask. The Agent fields use it to offer a dropdown. |

**Ask an agent and wait for the answer** keeps the flow waiting while the agent works, which usually takes a few minutes. Wordsmith answers `202 Accepted` until the answer is ready, and Power Automate checks back on its own. Set a timeout under the action's **Settings**, such as `PT1H` for one hour: a question that waits on a person's approval can otherwise hold the flow for days.

The action fails when the agent could not answer, so use **Configure run after → has failed** to handle it. When it succeeds, **Status** is `completed`, or `filtered` when the agent declined the question, with the reason in **Decline reason**.

The answer is Markdown. Headings, lists and bold text show their Markdown symbols in a plain email.

## Connect

1. In Wordsmith, open **Settings → API keys** and create an API key for the user the flow should act as. The key acts with that user's access, so a flow can do only what that user can do. A key limited to some scopes needs `me:read`, `agents:read`, `sessions:write`, `files:read`, `files:write` and `tasks:write`.
2. In Power Automate, add a Wordsmith action to a flow. When asked for a connection, choose your **Region**: Europe or United States.
3. Paste the API key, then **Create**.

## Example: answer a Microsoft Forms submission

This flow sends each response to a Microsoft form to an agent, and emails the agent's answer to the person who responded.

1. Create an automated cloud flow with the Microsoft Forms trigger **When a new response is submitted**, and pick your form.
2. Add **Microsoft Forms → Get response details**, with the same form and the trigger's **Response Id**.
3. If the form has a file upload question, get each file's content. Forms stores uploads in the form owner's OneDrive, and the answer holds a JSON list of files. Add **Parse JSON** on that answer, then **OneDrive for Business → Get file content using path** inside an **Apply to each**, then **Wordsmith → Upload a file** with the file's name and content.
4. Add **Wordsmith → Ask an agent and wait for the answer**:
   * **Agent**: the agent that handles these requests.
   * **Question**: the instruction, with the form's answers inserted from **Get response details**. For example: `Review this NDA request from <Responder's name>. Counterparty: <Counterparty>. Deadline: <Deadline>.`
   * **Files**: the **File ID** from each **Upload a file**.
5. Add **Condition**: **Status** is equal to `completed`.
6. Under **True**, add **Office 365 Outlook → Send an email (V2)**. Set **To** to **Responders' Email**, and the body to **Answer** and **Session link**.
7. Under **False**, email the form owner the **Decline reason**, so a declined request is not lost.
8. Add a step that runs only when **Ask an agent** has failed (**Configure run after → has failed**), and email the form owner, so a failed request is not lost either.

**Responders' Email** is filled only when the form records names, which requires respondents to sign in.

To have a person check the work before anyone sees it, use **Create a task** instead of step 4. Assign the task to an agent, put the form's answers in **Instructions**, and add **Attach files to a task**. The task appears in Wordsmith with the files, and the task's **Task link** can go in a confirmation email.

## Import the connector

An environment maker imports the connector once per Power Platform environment, with the [Power Platform CLI](https://learn.microsoft.com/en-us/power-platform/developer/cli/introduction). Import from the CLI rather than the **Import an OpenAPI file** page: that page reads only the API definition, so the connection loses its region and API key settings.

1. Get the connector files from Wordsmith support: `apiDefinition.swagger.json`, `apiProperties.json` and `icon.png`.

2. Sign in to your environment:

   ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
   pac auth create --environment <your environment URL or ID>
   ```

3. Create the connector:

   ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
   pac connector create --api-definition-file apiDefinition.swagger.json --api-properties-file apiProperties.json --icon-file icon.png
   ```

4. In Power Automate, open **Custom connectors**, find **Wordsmith**, and share it with the people who build flows.

## Limits

* **Upload a file** takes files of up to 3 MB. A file between 3 MB and about 4.4 MB is refused with a message naming the limit. A larger file fails with a server error, because the request is over the platform's size limit before Wordsmith reads it. For a larger file, pass a public link as the question's **Public file URL**.
* Files the agent created have two links. **Answer file download URL** expires 5 minutes after the answer arrives, so download it in the next step. **Answer file link** does not expire, but needs Wordsmith sign-in.
* The connector does not yet have a trigger for a finished task. To act when a task completes, poll **Get a task** in a **Do until** loop.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.