Start building your own chatbot now >

Chatfuel offers a great and easy to understand environment to build simple bots, really fast. Since the bot’s actions are triggered with button clicks, it’s incredibly easy to mockup a conversation flow and deploy it to Messenger.

Yet, experienced bot builders will tell you: the actual user inputs your bot will get are impossible to predict exhaustively, sometimes absurd and quite often senseless. A pure input-output logic will sadly not get you very far.

This is precisely the reason why NLP is essential for a chatbot to be able to react to unpredictable inputs. Hence, if you ever have shipped an application to Facebook, you know that this will happen very, very often:

How to add NLP to chatfuel's bots

A chatbot failing at smalltalk

Some people just won’t click the buttons and type weird questions instead. To give you some perspective, one of the most triggered intent on one of customer support chatbot for a bank is @ask-joke. You would think people have better things to ask to their digital bank clerks – the reality is that most users want both: the facts and the fluff.

Knowing this reality is one thing, handling it is another. If you fail to handle fluff in a satisfying manner, you’ll leave your users deeply frustrated. The good news is that integrating Natural Language Processing with Recast.AI to your existing Chatfuel bots only takes minutes, and I’ll guide you along the path.


By the end of this tutorial, your existing bot will be able to understand more than 15 different topics of small talk and answer it cleverly, and you’ll have everything you need to add much more – all that in less than 10 minutes. So, without further notice, here’s what on the menu today:

  1. Setting up a Recast.AI account
  2. Training your bot to understand and respond to small talk
  3. Interfacing Recast.AI and Chatfuel
  4. Setting up a fallback on Chatfuel

Find a comfortable spot, and get the stopwatch ready. Now it is the time to plug a Recast.AI brain into your Chatfuel’s bot!


  1. To begin, create an account on Recast.AI! It’s free 🙂
  2. It’s now time to log in and create your first bot. Click on the button “Start with a template”, or just on + NEW BOT in the header section

    Add NLP to Chatfuel bots

    Create your first bot on Recast.AI

  3. Choose “Create a complete chatbot”
  4. You can choose one or many pre-defined skills to generate a boilerplate for you bot. Pick Greetings and Small Talks
  5. Choose your bot name
  6. You can add an optionnal description
  7. Set English as the default language
  8. You can keep your bot public as there is no private info, but you can change this setting later

checkmarkStep 1/4 – Set up a Recast.AI account



The train tab is the default view on your bot, and it displays its intentsAn intent is a “box” of sentences that all carry the same meaning, even though they can be very different to one another. When a user sends some text to your bot, our algorithm compares it to the phrases in your intents. Then it checks if it’s close enough to one of them and decides what the intention of the message is.

Because we started with a boilerplate you will already see a lot of intents:

Give Chatfuel a brain

Overview of your basic intents

This means that your bot already knows how to recognize 16 different meanings in hand typed messagesIf you want to learn how to create new intents or improve the existing ones, I invite you to give a look at this tutorial.


The Build tab is where you find Bot Builder. It helps you construct the conversation flow of your bot using SkillsEach Skill represents one thing that your bot know to do, and they can interact with each other.

You can already see the two default skills, greetings and small-talk picked during the creation of the bot.


A skill has four parts:

  • Readme: Where you explain the purpose of your skill
  • Triggers: Where you define why this skill should be activated after a user message
  • Requirements: Describes what information this skill has to collect, and what questions need to be asked to fulfill the requirements.
  • Actions: What to do once the requirements are fulfilled

The two premade skills are very simple: they are triggered if the user message contains a certain intent and answer with a message depending on the intent. The skill greetings takes care of the intents greetings and goodbye, and the skill small-talk handles the 14 others.

By default there is no fallback message, meaning that if no intent was assigned to the message, nothing will happen.

Fix this by clicking on+ ADD A NEW SKILL the left, and choose skill type FALLBACK. Give it a name of your choice.Once it’s created click it to view its settings and go to the Actions tab. Click ADD A NEW MESSAGE GROUP, choose SEND MESSAGE action type and create a default message of your preference.

If you want to edit the default skills, go to their Actions tab and click the pen to change the content of the message.

The setup part on Recast is now done, you can test your bot by clicking the blue Test bubble on the right of the screen. The Converse tab shows you what answer is configured for a message and Analyse tab which intent was matched.

checkmarkStep 2/4 – Train your bot



Unfortunately, Recast.AI and Chatfuel don’t speak the exact same language. The JSON output from Recast’s Bot Builder is not formatted exactly as Chatfuel API expects.

Let’s code a simple NodeJS proxy to solve this issue. We’ll set up a simple HTTP server that receives events from Chatfuel, calls Recast’s Bot Builder API with the message sent by Chatfuel and returns the messages configured in your Skills.

Start by installing dependencies:

Then copy the following script to a .js file.

Now you should host this code on a public server so that Chatfuel send requests to your API.You can try Ngrok if you want to expose publicly a port of your local computer.

checkmarkStep 3/4 – Interfacing Recast.AI and Chatfuel



Finally, we need to configure Chatfuel to send a request to the proxy when the bot receives a free-typed message.

Choose the Default answer and reproduce this setup:

How to make Chatfuel bots smarter?

Setting up the fallback on Chatfuel


This will save the user message to a variable named user_message, and send a request using JSON API block to the proxy we created with two parameters: the message and a user id, to keep track of conversation states on Recast.

Your bot now understands small talk! Go test it on messenger:

A Chatfuel bot made smart

Talking with our bots on Messenger


checkmarkStep 4/4 – Setting up the fallback


Going further

Even if you have a functional Smalltalk module as is, you may want to personalize the texts of your bot, create new intents or improve the detection of your bot.

Everything you need to know about Intents and Skills is explained in this tutorial.

Take your time to improve the quality of your bot’s Smalltalk, it’s a very important part of its identity, and you will notice a much stronger engagement. The personality of a chatbot is a determining factor of its user retention rate.

Thank you very much for following along! We would be very happy to have your feedback on how small talks impacted your existing bots.

🤖 Happy bot building 🤖

Have an issue with your bot? Is something unclear in this tutorial? Feel free to comment or join our Slack to discuss it.

Want to build your own conversational bot? Get started with Recast.AI !

  • Ga Friedman

    Great and intelligent article, but I must dosagree about one thing. May I remind you that a bot SHOULD CONVERS WITH PEOPLE. This is the most (almost the only) strong advantage of bots. The conversation act.
    Now, you would never let any one who is not a programmer to program your software. You would never let someone who is not a mechanic, to fix you car. And I can go on with lots of examples.

    So why Do you think that the “script” part should be treated like anyone can do it? Like it’s a gimic? I have a guess why… 🙂 Don’t feel insulted, but it’s probably you, yourself, has no clue about it. You probably have never created, formatted, shaped a real written conversation, with all needed aspects inside.
    Just a disclosure – I’m a well experienced script writer (quite famous in my country). And I know how complicated it is. Bots will start being worth something only when people will understand that you cannot create a conversation without experts on that matter, and you don’t want to do it in 10 minutes. It’s the heart and the brain of your product. It is better to invest some thinking first 🙂
    Thank you very much
    Gal Friedman

  • Roldano De Persio

    Hi Nathan, unfortunately I am not a programmer at the moment 😉
    I am lost in the part
    npm install express axios.
    Could you please elaborate this part?
    I have seen other tutorial in which Dialogflow was coupled with Chatfuel.
    In one of this tutorial they used Runkit.
    Is it possible to have a similar example with Recast + Chatfuel?
    Merci 🙂

  • Amos


    very interesting article, thanks

    I tried to implement that with a glitch server.

    I have the following message in the my console when triggering the query :

    (node:8327) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Converting circular structure to JSON
    1:57 PM
    (node:8327) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

    Any idea on how to fix it?

    THanks !

    • Amos

      Here is a public glitch projet with a working code!/charming-staircase


  • Maxime

    Hi Amos,
    When I try to execute your project, I still have the same errors :

    (node:19698) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Converting circular structure to JSON
    (node:19698) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

    How did you fix it ?

    Thank you 😀

  • Maxime

    Ok, I have resolved the problem 🙂

    There is a typo error line 31, you just have to change :

    const userId = query[‘messenger_user_id’];
    const userId = query[‘messenger user id’];

    Cheers 😉

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies

Please confirm that you accept cookies to monitor the performance of our website