Skip to content

Use if/then branches in bots

Last updated: January 29, 2024

Available with any of the following subscriptions, except where noted:

Marketing Hub Professional, Enterprise
Sales Hub Professional, Enterprise
Service Hub Professional, Enterprise
Operations Hub Professional
CMS Hub Professional, Enterprise

Use if/then branches to customize the flow of bot conversations. You can add conditions to tell your bot to skip to a specific action based on the visitor's response, a contact property value, or your team's availability. Set up an if/then branch for bot actions, or for each quick reply response within an action.

Like with workflow branches, if/then branches enable you to send visitor's down a specific path depending on the criteria you set. For example, you can send visitors to different bot actions depending on if they answer "yes" or "no" to the bot question. This helps trigger different bot actions so you can tailor the flow of the conversation to the individual visitor based on the information that they provide. 

Please note: free users and Starter users cannot add if/then branches to their bot.

Set up an if/then branch for a bot action 

Add an if/then branch to a bot action to control which action comes next when the visitor meets certain criteria. 

  • Hover over the bot and click Edit, or create a new bot
  • In the bot editor, select an action.
  • In the right panel, click the If/then branches tab.
  • Click Add if/then branch.

ifthen-branch-chatflow-outline-2

  • Create conditions for this action. You can base the logic on the user's response, a contact property value, or agent availability. Click the first dropdown menu, then set your criteria:
    • Visitor's response: use this option to send visitors down a specific path based on their response. For example, you can send visitors to different bot actions depending on if they answer "yes" or "no" to the bot question.
      • Click the dropdown menu and select a filter option.
      • Click Add values, then type in any value you want to filter conversations by then click Enter.
      • Click the Next action if all conditions are true dropdown menu and select an action.

visitors-response-if-then-branch

    • Contact property: send a visitor down a specific path based on a contact property value. 
      • Click the Select a property dropdown menu and select a property.
      • Click the dropdown menu and select a filter option.
      • Click the Add values dropdown menu and select property values, or type in any value you want to create conditions for, then press Enter to add it to your list.
      • Click the Next action if all conditions are true dropdown menu and select an action.if-then-contact-property
    • Agent availability (Sales Hub or Service Hub Professional or Enterprise only): send a visitor down a specific path based on a team member's availability. For example, if a team member is unavailable, you can send the visitor to the Submit a ticket action so you can still track the visitor's issue. 

Please note: you can only select users from the dropdown menu who are assigned to a paid Sales Hub or Service Hub seat. Learn more about the requirements for automatically routing conversations

      • Click the first dropdown menu and decide who to route visitors to based on their availability:
        • Specific users and teams: send the visitor down a specific path based on the availability of a specific users or teams. Click the Add a user or team dropdown menu and select the checkboxes next to the users or teams to include.
        • Contact owner: send the visitor down a specific path based on their contact owner's availability. Click the If there is no contact owner, assign to dropdown menu and select a fallback option for any new or unassigned visitors who start a conversation. The user you select must have an assigned Sales Hub or Service Hub paid seat.
      • To set the logic based on whether the team member is available or unavailable, click the last dropdown menu and select is unavailable or is available.
      • Click the Next action if all conditions are true dropdown menu and select an action.
    • Click AND to create additional rules. 
  • Click Save.

You can also send a visitor back to a previous action. When you click the Next action if all conditions are true dropdown menu, select an earlier action from the dropdown menu. The contact will then "loop back" to the previous step.

loop-back-to-previous-action

Set up if/then branch for quick replies

If you're using quick replies in a bot action to display a series of preset responses during a conversation, set up if/then branches based on these quick replies. Depending on which preset response they select, the visitor will go to the specified action. 

  • Select an action to modify.
  • In the right panel, click the Quick replies dropdown menu and type to add answers that your visitor can select as responses to your message prompt. Press the Enter key to save each one. When chatting with a visitor, the quick replies will appear as selectable options. 

view-quick-replies-during-bot-conversation

  • To require that visitors choose one of your pre-determined answers, select the Disable open responses checkbox.
  • Click the Save to HubSpot property dropdown to select or search for the property that will store their response. 
  • After you enter your quick reply responses, click Go to action based on response to set up the if/then branch.

quick-reply-branch-builder

  • By default, the bot will send the visitor to the next action. Next to each response, click the Continue to next action dropdown menu and select another action. quick-reply-options
  • Click X next to an action to remove the branch.

Please note: if you click X to remove the branch, you will also remove the option as quick reply response. You'll need to re-add the quick reply response in order for it to display during a conversation.

  • After customizing your bot's logic, click the Otherwise, go to dropdown menu and select which action should come next if the visitor does not meet any of the conditions set.
  • Click Save
  • Review your branching logic, then click Save in the bottom left.

When a visitor engages with the bot on your website, they will go to the next action specified in your if/then branching logic based on which quick reply response they select.

Please note: you cannot delete an action that is using an if/then branch. Delete the if/then branch first, then delete the action.

Review branching

To view the path visitors will follow when they meet a certain condition, select an if/then branch response. The next action will display in the bot builder.

test-branching-logic

To review and troubleshoot your branching logic:

  • In the top right corner in the bot editor, click Go to action
  • Select an action from the dropdown menu. 
  • The action will appear in the bot editor for you to review and edit. 

use-go-to-action

 

Was this article helpful?
This form is used for documentation feedback only. Learn how to get help with HubSpot.