# Route conversations based on sentiment

<figure><img src="https://3861485111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU9kiDiTGVD8kkbnKKyEn%2Fuploads%2FprKvChyscrVEiQEbvuDD%2Fimage.png?alt=media&#x26;token=e0c130a8-bc66-4da1-84b5-938e591d893a" alt=""><figcaption><p>Click the image to see the flow in more detail</p></figcaption></figure>

## How it works

1. Conversation created: The flow is triggered when an incoming message is received from a customer.
2. Predict sentiment: The flow passes the incoming message through an AI sentiment analysis action. This tool will analyze the content of the message and classify it as either positive, negative, or neutral based on the emotional tone conveyed.
3. Conditional: The flow splits into three separate branches, one for each sentiment category (positive, negative, or neutral).
4. Add tags to a conversation in Inbox: Within each of the three branches, the next flow action adds a tag. For example, if the message is classified as positive, it adds a "positive" tag to the conversation.&#x20;
5. Assign to agent in Inbox: The next flow action routes the conversation to the agents who have also been assigned that sentiment to handle.

## How to use the flow

### What you’ll need

* At least one installed [channel](https://docs.bird.com/applications/channels/channels)
* Three [tags](https://docs.bird.com/applications/inbox/inbox/admin-guide/tags) set up in Inbox (Positive, Negative, and Neutral)
* Inbox [agents](https://docs.bird.com/applications/inbox/inbox/admin-guide/agents) with correlating tags

### How to setup

**Trigger**

1. Go to **Flows** > **Template library** and locate and select the ‘Routing Bot: Sentiment’ flow.

<figure><img src="https://3861485111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU9kiDiTGVD8kkbnKKyEn%2Fuploads%2F280dbYUHcvkPuB3ZS5RL%2Fimage.png?alt=media&#x26;token=bd79596b-9980-45c5-a39f-f55b6ea4f23a" alt=""><figcaption></figcaption></figure>

2. Click  **Save to my library** in the top right-hand corner.

<figure><img src="https://3861485111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU9kiDiTGVD8kkbnKKyEn%2Fuploads%2FwZ3LUpze9qxrLJgz2juu%2Fimage.png?alt=media&#x26;token=aa87b4be-7fe1-46d1-8026-5ad98e8ca6f8" alt=""><figcaption></figcaption></figure>

3. The trigger is automatically configured for WhatsApp, but you can change the trigger to a channel of your choice.

**Predict sentiment**

1. If you’ve changed the channel trigger, send a message to that channel, then run a test on the ‘Predict sentiment’ action to pull in the data from your message.
2. Click **Save** when you’re ready to move on.

**Add tags to a conversation**

1. Select one of the three sentiment branches.
2. Click the **Add tags to a conversation in Inbox** action.

<figure><img src="https://3861485111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU9kiDiTGVD8kkbnKKyEn%2Fuploads%2FmDhgqUVdxBdVhsNB4Lss%2Fimage.png?alt=media&#x26;token=9758a597-1664-483d-9378-484b6f6448e2" alt=""><figcaption></figcaption></figure>

3. In the Configuration > Tags field, type the name of the tag that you want to use. For example, if you are using the ‘Sentiment = Positive’ branch, search for the ‘Positive’ tag you’ve created for your agents.
4. Click **Run test** to check your tag configuration, then click **Next**.

**Assign to Agent in Inbox**

1. Click the **Assign to Agent** in Inbox action.
2. Click the **Tags** toggle to turn it on.

<figure><img src="https://3861485111-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FU9kiDiTGVD8kkbnKKyEn%2Fuploads%2FyJwnHpDyZiyreNY1mZ8w%2Fimage.png?alt=media&#x26;token=a67a4ca5-570c-4f50-ace1-98fc82cf920b" alt=""><figcaption></figcaption></figure>

3. Click **Next**.

Repeat the ‘Add tags to a conversation’ and ‘Assign to Agent in Inbox’ steps for each of the remaining two sentiment branches.

For the ‘Else’ branch, choose a default language tag for unrecognized languages, and make sure the flow jumps to that action.

Click **Publish flow** to start routing conversations based on sentiment.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bird.com/applications/automation/flows/how-to/route-conversations-based-on-sentiment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
