# How to set up the Recognize Intent step

In this guide, you'll learn how to automatically distinguish topic-specific customer messages and route them to the right agents from your team using the **Recognize Intent** step in [Flow Builder](https://dashboard.messagebird.com/en/flow-builder).

&#x20;

**How is it possible to automatically categorize text?**

To automatically categorize text, we’ll use machine learning. We’ll also take away all the complexity involved in building and deploying a machine learning model and make this work perfectly just by providing examples that describe the use case. From these examples, our machine learning algorithm also picks up the right category (what we refer to as *intent*) for messages that are slightly different. In other words, it automates intent recognition.

&#x20;

**Requirements**&#x20;

* * A [MessageBird account ](https://dashboard.messagebird.com/en/sign-up)
  * [WhatsApp for Business account](https://www.messagebird.com/whatsapp/) or any other channel from [MessageBird's offering](https://dashboard.messagebird.com/en/channels)
  * A workflow to handle the messages—[Flow Builder ](https://dashboard.messagebird.com/en/flow-builder)
  * **An** [**Inbox account**](https://inbox.messagebird.com/) **(optional)**

&#x20;

**Step 1: Create a dataset**

1\. Log in to your [MessageBird Dashboard](https://dashboard.messagebird.com/en/login) and go to [Knowledge Bases](https://dashboard.messagebird.com/en/knowledge-base)

2\. Click **Create new data set**

3\. Select the **Intent dataset type** and name it **Sales or Finance**

4\. Select **English**

5\. Hit **Next** and choose **Input manually**

&#x20;

**Step 2: Populate and publish the dataset**

1\. To determine the intent of an incoming message, you need to provide example phrases for each intent you’re trying to detect. In this case, we will define 5 example phrases of both Sales and Finance messages for now, but keep in mind that the more examples, the better. You can add more phrases later on.&#x20;

**Good practices**

* Have at least 2 intents per dataset.
* Try to come up with example phrases that are *mutually exclusive* (don’t strongly overlap).
* Choose intents that are easy to distinguish. If you feel your intents might be very similar and difficult to distinguish (e.g. ‘Finance’ and ‘Payments’), then the machine learning algorithms will probably find it difficult too!
* The more example phrases per intent, the better.

This is how a populated data set looks like:&#x20;

<figure><img src="/files/3BUCoUnjCPczKyjUmdK0" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/284oKmUpEYTSdjYPqk4l" alt=""><figcaption></figcaption></figure>

2\. Did you fill in the intent examples? Awesome! Time to publish the dataset. Press the  **Publish dataset** button in the upper-right corner.

Keep in mind that depending on the size of the **Knowledge Base**, it can take a few minutes for the algorithm to learn the data. After 5-15 minutes, the published changes will be updated and your new dataset will be available and ready to use!&#x20;

You can see an indicator of that process in the Datasets overview page. Once your dataset **Available**, the publishing process has been completed!&#x20;

**Pro-tip:** You can update an existing dataset by clicking **View & Edit**. After you make your changes, don’t forget to **publish** your dataset again. The older version will be active until a new version is published.

&#x20;

**Step 3: Connect it all in the MessageBird Dashboard**

1\. Log in to your [MessageBird Dashboard](https://dashboard.messagebird.com/en/login) and go to [Flow Builder](https://dashboard.messagebird.com/en/flow-builder).

2\. Select a flow (or create a new one). For this example, we are going to create a **new custom flow** with **WhatsApp** as a trigger.

3\. Add the **Recognize Intent** step from the Steps menu on the left. Drag and drop it in the flow and set the following configuration:&#x20;

* Dataset: Select the **Sales or Finance** dataset from the drop-down menu.
* Content to recognize: drag and drop the **incoming message** variable from the **Available variables** list on the top
* Fallback intent: we can set a default intent here in case a message comes in and none of the intents we’ve defined was found. Set that to **default**.
* Output variable: leave as **intent** for now.

<figure><img src="/files/XlnK16pd5XDTxN0hk1LQ" alt=""><figcaption></figcaption></figure>

4\. Add a **Branch step** from the Step menu on the left. Drag and drop it in the flow after the **Recognize Intent** step we just made.&#x20;

From the options, create 2 branches that check for the value of our **intent** variable. One branch should be checking if it equals **Sales** and the other if it equals **Finance**.&#x20;

5\. For this use case, we want to notify our sales team with the sales-related messages and our finance team with finance-related messages via email. To do this, add a **Send an Emai**l step in each of the branches that forwards these messages to the right team. All the messages that are not categorized as Sales or Finance, fall under the else branch.&#x20;

&#x20;

**Step 4: Connect to Inbox**

1\. All uncategorized messages will be forwarded to our support agents in [Inbox](https://inbox.messagebird.com/login). To do that, go back to your communication flow and add a **Create Inbox ticket** step below the **Else** branch.&#x20;

Done? Awesome! The final flow should look like this:

<figure><img src="/files/5p1CYXYAO8ToepezYzlT" alt=""><figcaption></figcaption></figure>

2\. **Publish** your flow in the top-right corner of your screen, and you're good to go!

3\. To try the flow, initiate a conversation with your WhatsApp or chosen channel. Different messages (sales, Finance or other) should be categorized accordingly. Check out this [demo video](https://www.youtube.com/watch?v=kzKU_4xmYC0) to see them in action!

And that’s it! 🎉 Now you know how to automatically distinguish topic-specific customer messages and route them to the right people on your team using Flow Builder.

&#x20;

**Improving Intent Recognition**\
Once the Intent recognition workflow is live, you can optimize how well it is able to recognize intents by adding more examples to the knowledge base. If intents are not recognized or incorrect, you can check the incoming messages and add them to the examples in your knowledge base or manually correct the intent.&#x20;

&#x20;

**Next steps**

Intent recognition is key in building a chatbot. To add more functionality to your workflow you can also introduce a question answering mechanism with the FAQ step. This step will learn to answer questions, similar to how it learned to recognize intents using a knowledge base. Learn how to do that in our [step-by-step guide](/connectivity-platform/inbox-for-good/activate-faq-bots.md).&#x20;


---

# 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/connectivity-platform/getting-started/how-to-set-up-the-recognize-intent-step.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.
