From zero to hero: Creating a chatbot with Rasa NLU and Rasa Core

AI assistants are a hot topic these days. Chances are that you have already had an encounter with at least one of them, as a user or as a developer. In this post, I would like to talk about a stack of software called Rasa, which you should definitely include in your toolbox if you would like to build conversational assistants yourself.

In short, Rasa NLU and Rasa Core are two open source Python libraries for development of conversational AI. They are packed with Machine Learning and handle natural language understanding and dialogue management tasks. Most importantly, Rasa stack is easy to use, you don’t need massive amounts of training data to get started and it is perfectly suited for production.

I have been building chatbots with Rasa stack for almost a year now and it is safe to say, that it has been a tool that I have been the most excited about throughout that time. And here is why:

  • It is open source. You own your data and you can hack things.
  •  It is developer friendly. You don’t even need to know Python to use it.
  •  It has an awesome community and highly involved developers. If you have any issues, just post a message on Gitter and someone from Rasa team or other developers will help you out.
  •  It is a great example of how applied research can be shipped to practice and empower thousands of developers around the world.

So… With all that in mind, I decided to make a tutorial on how to create a chatbot using Rasa stack completely from scratch. It is going to be an exhaustive tutorial, with a deep dive into Python (if you don’t code in Python, don’t get discouraged – check the Rasa documentation of how you can do it all without any Python whatsoever). I am going to build a simple Slack integrated weather bot, called Frank. I highly encourage you to follow along so grab a cup of tea and let’s build some chatbots! 🙂

Update: The devs of Rasa NLU and Rasa Core are doing an amazing job updating and improving these libraries. Since I recorded this tutorial there were quite a few things introduced to Rasa NLU and Rasa Core which brought some changes in how some things should be coded. To keep this video consistent with the code, I updated requirements.txt file so that it would install Rasa NLU 0.11.4 and Rasa Core 0.8.2 – the versions which I used when I recorded the tutorial. If you want to use the latest releases of NLU and Core, you can find this directory which contains the tutorial code, compatible with the latest releases of these libraries (keep in mind, that the code will slightly differ from the one shown in the video).

Useful links:

Data files used in this tutorial
Full code of this tutorial
Full code of this tutorial [Latest release of Rasa NLU and Rasa Core]

Rasa NLU documentation
Rasa Core documentation
Rasa: Open Source Language Understanding and Dialogue Management (paper)
RasaHQ Gitter

19 thoughts on “From zero to hero: Creating a chatbot with Rasa NLU and Rasa Core”

  1. Thanks for sharing, I see you you said you have around 1 year of experience. I wonder if you have any examples of a bot you built online already? Would be great to see it. Thanks.

    1. Hey, thanks for checking it out! 🙂 The biggest chatbot I have built so far is for internal use of the company which I currently work for, so I can’t share it online, unfortunately. If you are interested in what it is about, you can check this interview where I spoke a little bit about it https://medium.com/rasa-blog/building-bots-with-rasa-shiba-slack-hosted-interface-for-business-analytics-ed47f346a16b . Apart from that, I am currently in a process of developing another chatbot which I think will be worth sharing online. I will post about it here once it’s done 🙂

  2. Hi Justina,

    I really appreciate the effort you have taken inorder to put this really nice example out. I am currently also working on a Rasa_NLU , but its nice to see how i can integrate with Rasa_core .

  3. Hi there thanks for all the guidance. However, i am getting this error “Unable to find vcvarsall.bat”
    Installed python 3.5.2. Im stuck can you please help?

    1. Hey 🙂 I am pretty sure it is your Visual Studio complaining. Can you share some more details on your current setup? What VS version do you have and can you share a full error log? If you want to, you can drop me a direct message with those details.

  4. hey nice tutorial
    I tried on different data but even after giving around 40 stories next_action is always action_listen, can you help me?

    1. Hey, swaps. Thanks for checking it out! 🙂 Would you mind sharing your domain and some of your stories and nlu data with me so I could reproduce it? You can shoot me a DM on Twitter, Linkedin or send me an email.

    1. Hey Alisa! Thanks for checking it out. I hope you will continue using Rasa and creating cool chatbots 🙂

  5. Hi Justina,

    Thank you so much for creating this awesome content. It has got me started in chatbots. I have one question. How to give multiple choices to the user and then proceed with the user’s response?

    1. Hi Palash,

      Thanks for checking out the tutorial, I’m glad you found it helpful 🙂

      Do you want to implement buttons or do you want to keep it fully conversational? If you want to go the button route, then I would suggest you checking out Slack connector on Rasa Core https://core.rasa.com/connectors.html#slack-setup , it has a button functionality already implemented (if you need any help with using it, just shoot me a message). If you don’t want to use buttons, then in your domain file you should simply create a template or an action which will send a message with multiple options to your user and the user’s response should be parsed using NLU model and saved as a slot. Let me know if you need help with anything 🙂

      1. Can I keep it both conversational and buttons whenever needed? I think the button route is sometimes very useful when I want to avoid any user mistakes. And what if I want to integrate the chatbot with a website and not with the existing messenger platform?

      2. Hey. Yes, your bot can use buttons and conversational responses depending on which one is needed. You will only need separate actions for those cases. Speaking of custom integration – it shouldn’t be a problem to integrate your chatbot with a custom website, for this, you can run Rasa as an http server (more on this here: https://core.rasa.com/http.html) or you can create your custom connector (here is an example for a custom connector from Rasa https://github.com/RasaHQ/rasa_core/blob/master/rasa_core/channels/custom.py).

  6. HI Justina, Thanks for the awesome work. I followed it and it worked. But couple of queries. How do i not end the conversation until, i say good bye? The bot automatically goes to BYE intent after it answers the weather results? could i keep asking weather for multiple times and not end the conversation , until i say bye?

    Thanks
    Roshan

    1. Hi Roshan. I am glad you gave it a try! 🙂 I think your problem related to the lack of training data. In my example I had only a few stories and it is likely that the bot will make a lot of mistakes. Try adding more stories to stories.md file and see if that improves the performance 🙂

Leave a Reply