DEV Community

Cover image for Create Your Own AI Chatbot in minutes with Rasa
Saji Wang for Codesphere Inc.

Posted on • Updated on

Create Your Own AI Chatbot in minutes with Rasa

AI Chatbots are an increasingly popular way to service your users. They allow you to field diverse UX requests without pages and pages of buttons for every possible thing that a user might need.

The issue, however, is that building and training an AI chatbot can be an incredibly burdensome task that oftentimes simply isn’t worth the effort.

Rasa is attempting to change that. Rasa is an open-source tool to quickly create and train an AI chatbot for whatever purpose you need. You simply enter in near plain-english how you want your chatbot to operate, give it some example inputs, and then reap the benefits.

Setting up the Demo

You can quickly setup a demo in minutes with the following commands(Make sure you have python installed):

Setup the python environment and install Rasa via pip:

python3 -m venv ./venv
source ./venv/bin/activate
pip3 install rasa
Enter fullscreen mode Exit fullscreen mode

Setup, train, and run the Rasa project:
Rasa init

From there, Rasa will run the default chatbot in the command line for you to play around with

Image description

How to Customize Your Chatbot

Okay, if you’re following along you might have realized that the demo bot is pretty limited, so how can we add more functionality?

There are five key components to build your Rasa bot:

  1. NLU data
  2. Responses
  3. Stories
  4. Forms
  5. Rules

NLU(Natural Language Understanding) Data is the training data that you feed Rasa. You simply need give it examples of ways a person might say something, and then classify what those different messages mean into intents:

Image description

Responses are the ways in which you want your bot to be able to respond:

Image description

Stories are the paths that you want a conversation to be able to take:

Image description

Odds are you’re using your chatbot to collect some sort of data from users. Forms are the way you can structure requests that you need your chatbot to make and what to do when they successfully collect that information:

Image description

Finally, rules are exactly what they sound like. They can place strict requirements on ways your bot should interact:

Image description

After you edit all these parameters to customize your bot, make sure to retrain your bot with:

rasa train

How to Deploy your Chatbot

So now that you have customized your bot, how can you actually use it? Among other ways, Rasa allows you to deploy your bot as an API!

We’d recommend using Codesphere, an all-in-one web IDE and Cloud provider that allows you to deploy any app in minutes.

You can get your project setup in Codesphere simply by connecting the github repo and installing all the necessary dependencies through the command line.

When you are ready to deploy, simply run:

rasa run -p 3000

And the api will be running on port 3000.

We can then make post requests to the chatbot at:


With a json with the following format:


“sender”: “test_user”, // sender ID of the user sending the message

“message”: “Hi there!”

Enter fullscreen mode Exit fullscreen mode

Note that Rasa will automatically track user sessions from senders with the same sender ID, and will even clear inactive senders after a given time period(1 minute by default).

Rasa even provides a customizable chat widget for easy embedding:

Additionally, Rasa can be connected through Websockets, Slack, Telegram, and a myriad of other ways! You can learn more here!

And that’s all it took to get our chatbot live!

Let us know down below what you’re going to use your chatbot for!

Happy coding from the Codesphere team!

Discussion (3)

wjplatformer profile image

Nice product! Looking forward to test it out!

include profile image

Nice post. quick question about rasa - what if you want to integrate your bot's anwsers from another source? Is is possible to - given a question from a user; the bot can pick a reply from another data source other than a YAML file? 10x in advance.

sewangco profile image
Saji Wang Author

Unfortunately, Rasa only accepts YAML files as the source of training data, but you could definitely programmatically generate these YAML files in order to take it from a different source

You can see Rasa's best practices for producing NLU training data here: