How to integrate Bitext in Chatfuel

Chatfuel is one of the major chatbot development platforms with thousands of bots published and working. Their success cannot be discussed, however for nonspecialized users, is hard to achieve the development of a fully conversational bot. Why? Because it takes too much time to come up and tag manually all the sentences the bot must understand.

At Bitext, we love challenges, and we wanted to see if by introducing our technology on Chatfuel our bot performed better understanding more user requests. And this is the result: a bot that can understand negation and multiple intents and that has been trained without any hand-tagged data. 

Simplifying your bot training

The integration of Bitext services in Chatfuel is extremely easy. In this article, you will learn how to integrate our sentence rewriting service with a conversational bot in Chatfuel. The key idea is to use this sentence rewriting service as a middleware between your users and your bot. The middleware takes the users’ sentences, simplifies them, and sends that simplified version to your bot. Given this approach, you can train your bot only with a small amount of simplified input sentences, and you don’t need to worry about all the infinite variants and complex versions of those sentences: the Bitext middleware tackles that complexity and your bot only receives simple sentences that it is able to understand. Nowadays, this sentence rewriting system has been customized for Home Automation bots and is available in the following webhook:<token>

Note that <token> is a variable that you should instantiate with a personal token identifier that we can give you if you are interested.

We assume that you have another webhook that gives access to your Home Automation bot, trained in this simple way. Let’s say that the webhook is the following one:<token>

This webhook gives access to Homebot, a Home Automation bot developed by Bitext in DialogFlow.

  • How to put the pieces together using Chatfuel

So, given these two webhooks (the middleware and the bot), let’s build a pipeline in Chatfuel that integrates them. As you will see, it is extremely easy. Bots are built in Chatfuel by creating ‘blocks’. And every ‘block’ has different ‘cards’. Specifically, the pipeline for integrating your bot with the Bitext middleware will be represented in Chatfuel as a sequence of five ‘cards’ in a single ‘block’.

  • In the 1st ‘card’ we will declare two variables that will be used in the process: the variable ‘query’, where the sentence sent by the user will be stored; and the variable ‘rewriting’, where the normalized, simplified version of the original query provided by the Bitext middleware will be stored.
  • In the 2nd ‘card’ we will ask the user to send us a query. When the user types something, it is stored in the variable ‘query’ (defined in 1).
  • In the 3rd ‘card’ we send the content of the variable ‘query’ to the webhook of the Bitext middleware. The response of this webhook will be set as the value of the variable ‘rewriting’ (defined in 1).
  • In the 4th ‘card’, we send the content of the variable ‘rewriting’ to the webhook of the bot. The response of this final webhook will be finally sent to the user.
  • And in the last 5th ‘card’ we ask Chatfuel to go back to the beginning of the pipeline to start again the whole process.


More specifically, let’s explain how to build that ‘block’ with its ‘cards’ in Chatfuel. We assume that you are logged in Chatfuel with your Facebook credentials.

In the main dashboard, just click on the ‘Create a blank chatbot’ button. You will see a new page where you can set up a new bot. By default, this bot will have two blocks: ‘Welcome message’ and ‘Default answer’. There, you can customize the welcome message and the default answer of your bot.  

In order to build the ‘block’ where we will build our pipeline, you must click the ‘Add block’ button. As a result, an empty ‘block’ appears. Then, set the name of the block to ‘process_input’ and configure it by adding ‘cards’. See the ‘Add card’ banner where you can choose different kinds of ‘card’. If you click the ‘+’ button you can see the whole list of cards provided by Chatfuel. So, we will add the five ‘cards’ of our ‘block’:

  • The 1st one will be a ‘card’ of type ‘Set up user attribute’. Once you have created the card, set two attributes, ‘query’ and ‘rewriting’, with values ‘NOT SET’.
  • The 2nd one must be a ‘User input’ ‘card’. The value of the ‘message to user’ field will be a blank, the value of the ‘validation’ field will be ‘None’ and the value of the ‘save answer to attribute’ field will be ‘query’.
  • The 3rd ‘card’ is a ‘JSON API’ ‘card’. The value of ‘type’ will be ‘GET’, the value of ‘url’ will be ‘<token>’ (the url of the webhook of the Bitext middleware) and the value of ‘user attributes’ will be ‘query’ (reference to the parameter previously defined and used). The responses of this webhook must be a JSON with a field ‘set_attributes’ where the value of the variable ‘rewriting’ is instantiated. See for more information.
  • The 4th ‘card’ is also a ‘JSON API’ ‘card’. The value of ‘type’ will be ‘GET’ again, the value of ‘url’ will be ‘<token>’ (the url of the webhook of the bot) and the value of ‘user attributes’ will be ‘rewriting’ (reference to the parameter previously defined and instantiated with the value returned by the previous ‘card’). The responses of this webhook must also be JSON where the text retrieved as the answer to the user is specified. See again in for more information.
  • The 5th is a ‘Go to block’ ‘card’. Set the ‘redirect to block’ field of this ‘card’ to ‘process_input’. As you can see, the idea is to build an infinite loop where the system goes back to the ‘process_input’ ‘block’ after the current execution of the ‘block’ has finished.

After you have built this ‘block’, the bot is almost finished. You only need to add a new ‘card’ to the ‘Default answer’ ‘block’ (remember, one of the ‘blocks’ that Chatfuel provides by default for every bot). This ‘card’ must be exactly the same as the ‘Go to block’ ‘card’ added to the ‘process_input’ ‘block’. You have also to set the ‘redirect to block’ field of this ‘card’ to ‘process_input’. (Otherwise, the bot only returns the default answer). And that’s all. You have built your bot in Chatfuel with the Bitext middleware.

Now you need to publish it on Facebook. For that, click the ‘Connect to Facebook’ button. Then click ‘Create Facebook Page’. Give that page the name you want your chatbot to have (Homebot, for example).  Once your Facebook page has been created, go back to Chatfuel, select your bot, click again on ‘Connect to Facebook’ and click now in the ‘Connect to page’ button of the page you have just created. And your bot has been published.

Bitext middleware can be also integrated with other platforms, check them here


Get to know how to solve 3 of the most common problems in chatbots 

Subscribe Here!