Polaris000 / ContactBot

A simple demo chatbot that collects a user's contact information. Built using Rasa.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contact Information Chatbot v2

This is the example bot used I used in a recent workshop on Rasa.

The presentation discussed the basics of Rasa, starting from what a chatbot is, all the way to building one with Rasa.

This example builds on our v1 chatbot, the code for which you can find here.

Improvements over Chatbot v1

  • handles the sad path where the user may not want to provide information
  • handles the case where the user may provide on partial information, like only their name or only their email
  • provides the user with further actions once a valid name and email are supplied
    • the user can choose to end the conversation by choosing the "That's all" option
    • the user can provide another set of name and email by choosing the "Add More Information" option.
  • makes use of custom actions
  • makes use of rules
  • has mutliple stories to handle different scenarios

A few cases that are handled in v2 but weren't in v1:

The user isn't willing to provide their information

πŸ‘¨ : Hey

πŸ€– : Please provide your contact information

πŸ‘¨ : don't want to

πŸ€– : Sorry! You'll have to provide your information to proceed.

The user provides only partial information

πŸ‘¨ : Hey

πŸ€– : Please provide your contact information

πŸ‘¨ : Sure. The name is John.

πŸ€– : Thanks. Could you also provide your email?

The user provides no information

πŸ‘¨ : Hey

πŸ€– : Please provide your contact information

πŸ‘¨ : Sure.

πŸ€– : Please provide your contact information

The user is shown further actions and chooses to end the conversation

πŸ‘¨ : Hey

πŸ€– : Please provide your contact information

πŸ‘¨ : Sure. Its john. And email is john@email.com

πŸ€– : Thanks! What would you like to do next?
    - That's all
    - Add More Information

πŸ‘¨ : That's all

πŸ€– : Thanks for your time!

The user is shown further actions and chooses to add more information

πŸ‘¨ : Hey

πŸ€– : Please provide your contact information

πŸ‘¨ : Sure. Its john. And email is john@email.com

πŸ€– : Thanks! What would you like to do next?
    - That's all
    - Add More Information

πŸ‘¨ : Add More Information

πŸ€– : Please provide your contact information

Contents

This project follows the format of a standard Rasa project. There's a directory called data for training data like nlu, stories, and rules.

There's a directory called actions, which contains all your custom actions.

You'll also find the domain.yml file, which mentions all your intents, entities, slots, responses and actions.

Finally, there's the config.yml file, which specifies the components your bot is comprised of.

Usage

  1. Clone this repo
  2. Navigate to the RasaChatbot directory
  3. Install rasa>=2.6.2 in an env.

Modify the files in data/ or the domain.yml file to play around.

Training the bot

Validating the data

Before training the bot, a good practice is to check for any inconsistencies in the stories and rules, though in a project this simple, it's unlikely to occur.

$ rasa data validate

Training

To train the bot, we simply use the rasa train command. We'll provide a name to the model for better organization, but it's not necessary.

$ rasa train --fixed-model-name contact_bot_v2

Chatting with the bot

To test your bot, open a new terminal window and start a rasa shell session.

$ rasa shell

This will let you chat with your bot in your terminal. If you want a more interactive UI and a little more debugging information like what intents were identified and what entities were extracted, you can use Rasa X.


You can find me on medium here.

About

A simple demo chatbot that collects a user's contact information. Built using Rasa.


Languages

Language:Python 100.0%