Want to build your own Personal Chatbot !?

Ana Jessica
featurepreneur
Published in
3 min readAug 15, 2021

Chatbots are software applications that use artificial intelligence and natural language processing to understand what a human wants, and guides them to get their desired outcome with very little effort of the user. Simply a virtual assistant!

Is it really that difficult to develop our own bot?

Fortunately, the answer is NO. Thanks to RASA, developing a chatbot is much easier now.You can now build your own chatbot easily without even have to think about that complex system anymore!

How cool is that!

Installing RASA

  • Create a new virtual environment in conda. This will allow you to run Rasa without errors.
conda create -n rasa python=3.6
conda activate rasa
  • Create a new folder. This command will create a Rasa Project at that location.
mkdir rasa-bot
cd rasa-bot
rasa init

Follow the interactive session and continue pressing enter to reach the last step. At the end of it, it trains and saves the initial model in the given directory. You can also interact with the bot in the command prompt.

  • Rasa created a sample Bot for you with default data. So now you can interact with the bot in the command-prompt by using:
rasa shell

Now let’s see, how to feed our faq’s to it.

Training Our Bot

Step 1: Changing the configuration Files

Rule policy has to be added to the config.yml file.

policies:- name: RulePolicy

ResponseSelector should also be added to the config.yml file.

pipeline:- name: WhitespaceTokenizer- name: RegexFeaturizer- name: LexicalSyntacticFeaturizer- name: CountVectorsFeaturizer- name: CountVectorsFeaturizeranalyzer: char_wbmin_ngram: 1max_ngram: 4- name: DIETClassifierepochs: 100- name: EntitySynonymMapper- name: ResponseSelectorepochs: 100

Step 2: Writing the rule

Write the actual rule in the rules.yml file. This is common for all our faq’s.

rules: - rule: respond to FAQs steps:  - intent: faq  - action: utter_faq

Step 3: Updating the nlu.yml file

The intents in the nlu.yml file for our faqs are written as :

nlu: - intent: faq/ask_name examples: | - What is your name? 
- May I know your name?

Step 4: Defining the responses in domain.yml:

The responses to our faqs are written as :

utter_faq/ask_name:- text: I am the Featurepreneur Bot, here to help you!

Also, all faq intents are defined with a single faq in the domain.yml file:

intents:- faq

Similarly you can add greetings or conversations as a rule, in rules.yml and add their responses in nlu.yml and domain.yml respectively.

Step 5: Run our bot:

After making the necessary changes in the rasa-bot directory, train the model for the changes to take effect. Test it in the command prompt.

rasa trainrasa shell

To increase the accuracy, add more examples in nlu.yml.

Lookout for the the next article, to see how to add UI fot the Chatbot.

Till then, play around, have fun and give your own twist to the Chatbot!

--

--