# AI Agent & AI Action in Flows

* When you log in through [live.fastn.ai](https://live.fastn.ai) into your Fastn account, navigate to **Flows** and create a new flow by clicking on **Create Flow.**

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FXrIX9hzShTP6eshF841D%2Fimage.png?alt=media&#x26;token=ff9a331c-8f5f-4071-a161-6c2e225c7dd0" alt="Fastn Flows page with the Create Flow button"><figcaption></figcaption></figure>

## Building your AI Agent On Chat Request

* Select the starting point for your flow. For example, if you want to build your AI agent in **Fastn** through chat message, select **On Chat message**, name your flow, and click on **Build** to start.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FMoimh7FBZqfyhFVaC22Q%2Fimage.png?alt=media&#x26;token=031e5184-2af6-4ad0-83f0-22d44d464861" alt="Flow starting point selection with On Chat message option highlighted"><figcaption></figcaption></figure>

* Click on the **"+"** symbol within your Flow canvas.
* In the component search bar, type **“AI Agent”** and select it.
* In the AI model section, select an AI model of your choice.
* Next, from the **model dropdown**, choose the AI model best suited for your use case (e.g., **Gemini 2.0**).
* Under the **Prompt** section, define the input the agent should use, for example:\
  `{{input.chatInput}}`
* Adjust your **Session ID**, **Memory Table Name,** and **Memory Content Limit** as required.
* Click **Save** to confirm your configuration.

{% hint style="info" %}
The Fastn AI Agent is in the beta category and under trial.
{% endhint %}

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FNV7XrKXV9BQo9XyTzvo1%2Fimage.png?alt=media&#x26;token=bd13134f-9ed8-4099-8c42-f3cc21cda4e7" alt="AI Agent configuration panel with model selection, prompt input, and memory settings"><figcaption></figcaption></figure>

* You will now need to get into the loop of your connected AI Agent to select your apps to connect and set up necessary actions.
* Select your desired app by searching for it in the **Connector** and connecting your account.

### Example Use Case: Fetching Your Contacts From Intercom

* Select the **Intercom** Connector and endpoint **Get Contacts** in this case, and click **Next.**

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F2EDYQYoomK70uMMJjaCj%2Fimage.png?alt=media&#x26;token=5854bfc2-b016-495c-9683-54d08c1eea4e" alt="Intercom connector selected with Get Contacts endpoint"><figcaption></figcaption></figure>

* In the next **Connect** section, connect your Intercom account to **Fastn**. Configure your action in the next step, and you will then see the Get Contacts action connected in your Flow.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FoiIcKV00VWqea8XpEPSn%2Fimage.png?alt=media&#x26;token=387ca8f6-7550-4051-a5ab-8a676d955245" alt="Get Contacts action connected in the AI Agent flow canvas"><figcaption></figcaption></figure>

{% hint style="info" %}
Inside each connected tool, you can add or delete individual parameters and map them to input values that are static or defined automatically by the model, as shown below. You can learn more about data mapping from [data-mapping-in-flows](https://docs.fastn.ai/flows/flow-setup-essentials/designing-a-flow/data-mapping-in-flows "mention")
{% endhint %}

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FiZ9nuDr38VP3zX5MxDtH%2Fimage.png?alt=media&#x26;token=72709a7b-63a1-4ffd-b955-d49209bd71dc" alt="Tool parameter configuration with mapped input values inside the connected connector"><figcaption></figcaption></figure>

* Go to the **Chat** option in the top-right corner of the screen.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FFPYQezXc5PRyqw9It8Jc%2Fimage.png?alt=media&#x26;token=32372c64-659f-4381-898e-5550c8ed35d0" alt="Chat option button in the top-right corner of the flow editor screen"><figcaption></figcaption></figure>

* Type the prompt you want to execute.

```
“Get my last 5 contacts from Intercom”
```

* The chatbot will process your request. You’ll receive the result showing the contacts along with details such as when each contact was created.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FCrbLPrJBii6I7tzlKwMu%2Fimage.png?alt=media&#x26;token=73ec21ef-0f14-4889-ac6f-d939b4346d87" alt="Chat response showing retrieved Intercom contacts with creation date details"><figcaption></figcaption></figure>

## AI Action

AI Action is your tool in Fastn to trigger action in your connected apps based on a single prompt without any model selection or complex flows.

### Building your AI Action on API Request

* Select the starting point for your flow. For example, if you want to trigger any task in **Fastn** through an API request for seamless system integration, select **On API Request**, name your flow, and click on **Build** to start.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2Ff5uz7Ynb5wpkoDEprMlU%2Fimage.png?alt=media&#x26;token=d1ae4d87-71bc-4449-ad32-cd56c5d2a65e" alt="Flow starting point selection with On API Request option highlighted"><figcaption></figcaption></figure>

* Inside the flow search and add the AI Action flow component.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F9ab0xLxsCHP2D3eHJp7J%2Fimage.png?alt=media&#x26;token=c240c3bf-530a-4893-81b2-b2d250f5e5d2" alt="Adding the AI Action component from the flow component search bar"><figcaption></figcaption></figure>

* In the AI Action connector, click on **Add Actions** to select relevant apps for connection and to update the necessary actions \[functionalities] for your task.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FBBBNfdn10ddGztRj8GaC%2Fimage.png?alt=media&#x26;token=c88fe1d5-6ebb-41c7-bf92-93caf2068b3c" alt="AI Action connector panel with Add Actions button for selecting apps"><figcaption></figcaption></figure>

### Example Use Case: Sending a Message to your Slack Channel

* Search for the Slack Connector and enable the Send Message Action after authenticating your Slack account.

{% hint style="info" %}
Your connector will appear as **Connected** after successful authentication.
{% endhint %}

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F4zIe8UHQvjnKWY29aM2s%2Fimage.png?alt=media&#x26;token=1c79f3d6-7368-40bc-8a90-b27a8c1a584a" alt="Slack connector with Send Message action enabled and account connected"><figcaption></figcaption></figure>

* You can now write a simple prompt with the message you want to send with the Channel Name e.g,

```
"Send a message test to Slack Channel ai_testing"
```

* Click **Save** and test run your flow by clicking **Test** from the top-right corner.

{% hint style="info" %}
You can deploy the flow to any of your selected environments to go LIVE.
{% endhint %}

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FK5aat4oBvgXRtd8nC9RR%2Fimage.png?alt=media&#x26;token=b6c329f9-06b7-49cf-b3e5-84fa2630fb73" alt="AI Action flow with prompt configuration and Test button in the top-right corner"><figcaption></figcaption></figure>

* You will now see your flow ran successfully and the message would be sent to the respective Slack channel.

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2F3M7bZHRh4J64r3CHjHqs%2Fimage.png?alt=media&#x26;token=1a82fbdc-3b13-46a9-ae2a-685a85b529f6" alt="Successful flow execution result showing the Slack message was sent"><figcaption></figcaption></figure>

<figure><img src="https://1255842839-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3iSr2Tx8FvvuoLPncziH%2Fuploads%2FnXkMFwbxr25jb0ughJrh%2Fimage.png?alt=media&#x26;token=23764481-7461-4371-b507-164a920b5fba" alt="Slack channel displaying the test message sent by the AI Action flow"><figcaption></figcaption></figure>
