Skip to main content

AI Agent routing

A very useful feature of rules

is the ability to perform actions after the conversation has started. In this guide, we will show you how to reassign the conversation to a different AI Agent using rules and tags in a dialog.

The plan

We will continue with the agent we created in Build an AI Agent

. In this example, we have a gym, and our Upsell Agent handles the payment of the membership. But what happens if the user wants to change their membership plan? We will create a rule that will assign the conversation to a different Agent, the Change plan Agent, when the user asks to change their membership plan. This last Agent will be of the Customer Support type.

To accomplish this, let's create a new dialog in Agent 1 that will be triggered when the user asks to change their membership plan. In this dialog, we will use a tag that will be evaluated in the rule we are going to create. This rule will assign the conversation to the Change plan Agent.

note

To see how to create an AI Agent from scratch, take a look at this guide

.

Create the dialog

A dialog

is a set of messages that the AI Agent sends to the user. In this case, we are going to create a dialog in the Upsell Agent that will be triggered by an intent that matches when the user asks to change their membership plan.

Intent

  1. Go to Build > AI Agents.
  2. Click on the Upsell Agent.
  3. Go to Conversation > Intents.
  4. Click on Create intent.
  5. Name the intent Change plan.
  6. Add some examples of what the user might say when they want to change their membership plan. For example:
    • I want to change my membership plan.
    • Can I change my membership plan?
    • How can I change my membership plan?
  7. Click on Save.

Dialog

The key point of this dialog will be the replay action. This action will trigger a message on the user's behalf that will be evaluated in the rule we are going to create. This message will not be visible to the user, but it will be evaluated by the rule and shown in the logs.

  1. Go to Conversation > Dialogs.
  2. Click on Create dialog.
  3. Name the dialog Change plan.
  4. Drag the Intent action from the right sidebar to the canvas.
  5. Select the Change plan intent in the dropdown list.
  6. Add a text response message to the dialog. For example:
    • Sure! I can help you with that. Let me assign you to our Customer Support Agent.
  7. Add a tag to the dialog. This tag will be evaluated in the rule we are going to create. For example: change_plan.
  8. Finally, add a replay action to the dialog.

Create the rules

Now that we have our dialog ready, we need a way to connect the Agent to the user. First, we must create a rule that will assign the conversation to the Upsell Agent. This rule will be triggered when the user starts a conversation. Then, we will create a second rule that will assign the conversation to the Change plan Agent when the tag change_plan is evaluated.

warning

This routing cannot be tested using the Agent test feature. You must test it in a real conversation because that only works for testing the Agent functionality, not rules.

Assign to Upsell Agent

  1. Go to Deploy > Rules.
  2. Click on + Add rule.
  3. Fill out the form and click on Create.
  4. Set the When field to A customer starts a conversation.
  5. Set the Then field to Assign to Agent and select the Upsell Agent.
  6. Activate the rule and click on Save.

Assign to Change plan Agent

Follow the same steps as the previous rule, but set the If field to Tag is change_plan and the Then field to Assign to Agent and select the Change plan Agent.