When you use Freshchat as your customer-facing widget, your customer will first see Topics. Topics are specific messaging channels that your customers can use to connect to your team. Depending on the Topic, you can offer specific support. If you’re using bots, you can trigger a different bot flow for each Topic. If you have multiple Whatsapp numbers connected to your Freshchat account, you can even set up unique bot flows for each of these numbers.


When you’re using Freshchat BYOB, you can have only one bot connected to your Freshchat account at a given point in time. You can build the bot flows for the different topics and Whatsapp numbers in the same bot, and use conditional logic to trigger the relevant bot conversations to your customers.


TABLE OF CONTENTS


Setting up the API

  • Open the API library of the bot in which you want to set this up.

  • Create a new API that you will use to recognize the Topic in which your customer has initiated the Freshchat conversation.

  • Configure the API endpoint in the URL section. This will change based on your data center of your Freshchat  account.

    India DC: https://api.in.freshchat.com/v2/conversations/<external ID>
    Europe DC: https://api.eu.freshchat.com/v2/conversations/<external ID>
    US DC: https://api.freshchat.com/v2/conversations/<external ID>
    Australia DC: https://api.au.freshchat.com/v2/conversations/<external ID>


  • Set the method for the API call to GET.

  • The external ID for the endpoint is a placeholder that stores the conversation id from Freshchat. To insert this placeholder, click on + icon in the URL text editor >  Placeholders > External Ticket ID.


  • Add the Authorization Header, as shown below. The Authorization key is “Bearer <API Token>”. To get the API token, open your Freshchat account settings > API Tokens > Generate/Copy an Existing API token

  • Choose the channel_id, as the Required Response Parameter. This will return the channel ID to your bot, which can then use conditional logic to decide which bot flow or Whatsapp number to trigger.

Setting up the conditional logic

  • When a customer says hello, Freshchat triggers the Hello flow, and for any other message it triggers the the “Sorry” flow. To ensure that your customer experience is seamless, mark the first dialog in the “Sorry” flow as a Private dialog, and connect it to the first dialog of the "Hello" flow.



  • Open the first dialog in your “Hello” flow and mark it as private. In the Actions tab > pick Trigger API > pick the API that you configured earlier. In our example, it was Fetch source.


Getting the channel IDs from Freshchat

  • Before configuring the conditional logic for the different Freshchat topics/Whatsapp numbers, you’ll need to get the channel ID associated with each of these topics/Whatsapp numbers. To get this, you can trigger the List All Channels API in an API tool.



Setting up the conditional logic

  • Go back to the bot that you were setting up in Freddy Self-service. Open the flow where you configured the Trigger API action, and switch to the Conditions.

  • Here, you need to configure a condition that will check the channel ID returned by the API call, in our case, the response parameter from the Fetch Source API. 

  • In the Conditions tab, set up a rule so that the bot detects the channel ID or the Topic where the customer has initiated the conversation and trigger the appropriate bot flow. 

  • Once it has the channel ID, it will look for a match with the list of channel IDs from Freshchat. If the channel ID returned from the API call is found to be equal to a channel ID associated with a topic, the condition will route the bot flow to that Topic.


  • In our example, the Freshchat account has two topics: Sales and Support. Based on which Topic the customer initiates a conversation from, the bot will trigger different flows.