How to create a Blip Bot Router

Gabriel Rodrigues dos Santos
9 min readDec 18, 2020

Learn the basics on how to create a blip bot router

Sometimes you have big or complexes bots flows that would be easier to handle if they were divided by any subject you want, to do such a thing we have bot routers, and to use blip’s routers you have to understand a few concepts:

  • A router works like a hub of bots;
  • Bots added to the router are called services;
  • All services are able to redirect between themselves;
  • Each service can redirect to other service (in the same router) at any point of the flow;
  • Every router needs a main service;
  • New users always start on the main service;
  • Services have expiration time by default, except the main service;
  • You can disable expiration time when adding a new service, this will prevent your users to be redirected in the middle of the flow to the main bot when time expires;
  • The name given to a service will be used to redirect.

Other important thing you have to keep in mind is: by default contacts are differents through services, that means that if you change any contact info on service A the same contact in service B won’t be affected, also by default, every track event and context variables are only saved in the specific service and not available to all. However, for the glory of the helm, we have a brand new option in each bot flow configuration called “Use router context”, when this option is enabled, all actions, contacts and variables are unified in the router, this means that every change in the contact will be reflected to all bots, context variables will be available and event tracks will be registered in the router.

But… when should I use it?

Imagine a bot that can attend 2 different sectors of the same company, in this scenario you can have 2 specialists that will handle contents of each sector and a main bot that can show available contents and redirect to the specialists that will do the hard job. In this situation we would have something like this:

We are ready, let’s do it!

Creating the router

The first thing you need to do is create a new bot router.
Go to blip and click on “Create router”

After that, click on “Create”

Set the router name and click on “finish”

You’ll be redirected to router’s dashboard.
At this point, you can notice that we have a red badge on the bot icon

It means that our bot isn’t online, to make it work we need at least one main service connected and published, so, let’s create our main bot.

Creating the main bot

First, click on “Create chatbot”

Select “Create from scratch”

Set the main bot name and click on “finish”

You’ll be redirected to the bot’s dashboard. At this point we can activate router’s context.

Router Context

To do so, go to “builder” section and then click on the “configurations” icon on the left. You’ll see a panel like that

The first thing to do is make sure that the “Flow identifier” value is different than 0, if it isn’t then you need to click on “Reset flow identifier”. After that you can select the “Use router context” option.

Adding services

Now you can publish your flow and go back to the router dashboard to add it as a service.

In the services tab you’ll see the “Add a service” button, click that and it will show you some options to add the service

  • The first option is the bot name, this name will be used to redirect to that service with the redirect command, so choose a meaningful name;
  • The second option is the bot itself, you can search by name and click on the bot you want to add;
  • The first checkbox must be set when adding a main bot, this bot will be the landing bot to new users;
  • The second checkbox only appears when you’re adding a bot that isn’t a main bot, when this box is checked the user will be stuck at the your subbot flow until you redirect him to other bot;
  • If you don’t check the second checkbox then you should set the redirect timeout, and if you won’t the default timeout is 30 minutes, it means that the user will be automatically redirected to the main bot after the redirect timeout (default or not).

As we are adding a main bot we will check the first checkbox, and after that you can click on “confirm”.

Now our router works and the badge on the icon is green! But keep in mind that you will have access to the bot through the router, not the main, so if you add any channel to the bot it must be set on the router.

I want more services!

We will create two bots, Tutorial specific 1 and Tutorial specific 2, using the same steps as for creating the main bot, the only difference is that this time you will have to set different names to the services and set they to not automatically redirect.

At the end you will have 4 bots and your router services will look like this

Now that we are able to redirect between services, let’s add some actions!

Redirecting

We’re going to do a simple thing: two options will be displayed on our main bot, the first option will redirect to the specific 1 and the second to the specific 2!
Both specific bots will receive any input, redirect back to the main bot and return the user to the bot’s initial state. After the main bot redirect the user to the specific 1 we will direct user to his initial state on main, but, for learning purpose, when the main bot redirects to specific 2 we will direct the user to another block instead of the initial block.

On the main bot:

  1. In the Welcome block
    1.1. Add a quick reply

2. Add two leaving actions (both “redirect to service”, we’re going to use conditional actions 😃)
1.2.1. In the first action
1.2.1.1 Put the Service as “specific 1” (the name must be exactly the same as in router services)
1.2.1.2. As our subbots will always start at the “start” block, we need a user input, we can bypass that sending any content as context, to do so we need to activate the “send message” option and put anything in the textbox (like a dot or whatever).
1.2.1.3. Now, let’s add our condition if User input is Equal to "First option"

2.2. In the second action
1.2.2.1 Put the Service as “specific 2” (the name must be exactly the same as in router services)
1.2.2.2. As our subbots will always start at the “start” block, we need a user input, we can bypass that sending any content as context, to do so we need to activate the “send message” option and put anything in the textbox (like a dot or whatever).
1.2.2.3. Now, let’s add our condition if User input is Equal to "Second option"

2. Add a new block called “waiting return” (this will wait til a user input (or redirect with context))

3. Add a new block called “back from 2”

4. On “waiting return”
4.1. Add a new output condition to Go to back from 2 If User input Exists

5. On “back from 2”:
5.1. Add a new text content “Back from specific 2, input anything to reset” and remove the User input

5.2. Add an output condition Go to Start If User input Exists

6. Back to the Welcome block on the output conditions
6.1. Add a condition to Go to to Start If User input is Equal to "First option"
6.2. Add another condition to Go to waiting return If User input is Equal to "Second option"

7. Publish your flow

On the specific 1/2: Both will do the same thing (just change texts)

  1. On Welcome block
    1.1. Add text content “You are in specific 1, send anything to go back to main” (change to specific 2 or whatever)
    1.2. Add a action “Redirect to service” as leaving action
    1.2.1. Set service as “main” (Must be exactly the same as your main bot name is router services)
    1.2.2. Enable “Send message” and set anything as “Context value”

1.3. On output conditions
1.3.1. Add a condition to Go to Start If User input Exists

2. Publish your flows

Testing!

Go to your router to test the bot, start a conversation and everything should work as expected!

Always keep in mind

  • Every time you redirect to another bot your user will still be “running” on the flow of the source bot, so, whenever you redirect it’s good for you to wait an user input, that way you will hold the user in that point of the flow;
  • You can use Context values to pass an information to other bots when redirecting, but we have unified contexts with router’s contexts so it’s better to do that by saving a real context variable;
  • The trackings made in all bots of a router will be registered in the router;
  • Artificial Intelligence it’s not bot specific, it’s retrieved from the router’s artificial intelligence, so you need to manage intents and entities on the router;
  • Contact identity is only the same if you’re using router’s context;
  • Desk is not on router, so all tickets and the identity of the contacts on the tickets are from tunnel domain and they are not the same as the router’s ones.

Conclusion

You can use blip’s routers to achieve complex and big bots without making a mess with your flows by diving the skills into subbots and reuse them as long as you need.

That’s it!

--

--