• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 5 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rasa Helpdesk Assistant Example

This is a Rasa chatbot example demonstrating how to build an AI assistant for an IT Helpdesk. It includes an integration with the Service Now API to open incident reports and check on incident report statuses. Below is an example conversation, showing the bot helping a user open a support ticket and query its status. You can use this chatbot as a starting point for building customer service assistants or as a template for collecting required pieces of information from a user before making an API call.

Here is an example of a conversation you can have with this bot:

Screenshot

Table of Contents

Setup

Install the dependencies

In a Python3 virtual environment run:

pip install -r requirements.txt

To install development dependencies, run:

pip install -r requirements-dev.txt
pre-commit install

With pre-commit installed, the black and doctoc hooks will run on every git commit. If any changes are made by the hooks, you will need to re-add changed files and re-commit your changes.

Optional: Connect to a ServiceNow instance

You can run this bot without connecting to a ServiceNow instance, in which case it will send responses without creating an incident or checking the actual status of one. To run the bot without connecting ServiceNow, you don't need to change anything in actions/snow_credentials.yml; localmode should already be set to true

If you do want to connect to ServiceNow, you can get your own free Developer instance to test this with here

To connect to your ServiceNow developer instance, configure the following in actions/snow_credentials.yml:

  • snow_instance - This is the address of the ServiceNow developer instance, you don't need the leading https.

  • snow_user - The username of the service account for the ServiceNow developer instance

  • snow_pw - The password of the service account for the ServiceNow developer instance

  • localmode - Whether the action server should not try to reach out to a snow_instance based on the credentials in actions/snow_credentials.yml. When set to True (default in the code), it will just take all the data in and message out the information that would normally be sent.

Running the bot

Use rasa train to train a model.

Then, to run, first set up your action server in one terminal window:

rasa run actions

In another window, run the duckling server (for entity extraction):

docker run -p 8000:8000 rasa/duckling

Then to talk to the bot, run:

rasa shell --debug

Note that --debug mode will produce a lot of output meant to help you understand how the bot is working under the hood. You can also add this flag to the action server command. To simply talk to the bot, you can remove this flag.

You can also try out the bot locally using Rasa X by running

rasa x

Refer to our guided workflow in the Wiki page for how to get started with Rasa X in local mode.

Things you can ask the bot

The bot has two main skills:

  1. Opening an incident in ServiceNow.

  2. Checking the status of incidents in ServiceNow by email address of the caller. It will prompt the user to re-use previously provided (during the chat session) email addresses, if any exist. For the purposes of illustration, the bot recognizes the following as requests to open an incident:

  3. Asking to open an incident directly e.g. "I want to open an incident"

  4. Asking about a problem resetting their password e.g. "I can't reset my password"

  5. Asking about a problem with outlook/email e.g. "I can't log in to my outlook"

Take a look at data/nlu.md to see what the bot is currently trained to recognize.

It can also respond to requests for help (e.g. "help me").

If configured, the bot can also hand off to another bot in response to the user asking for handoff. More details on handoff below.

Example conversations

With localmode=true:

Bot loaded. Type a message and press enter (use '/stop' to exit):
Your input ->  hi
    Hello!
    I can help you open a service request ticket, or check the status of your open incidents.
    You can ask me things like:
    - Open an incident
    - Help me reset my password
    - I'm having a issue with my email
    - What's the status of the ticket I opened?
Your input ->  i have a problem with my email
    What is your email address?
Your input ->  [email protected]
    ? What is the priority of this issue?
Your input -> 1: low (/inform{"priority":"low"})
    What is the problem description for the issue?
Your input ->  Can't log in to my email
    ? Should I open an incident with the following details?
    email: [email protected]
    problem description: Can't log in to my email
    title: Problem with email
Your input -> priority: low  1: Yes (/affirm)
    An incident with the following details would be opened if ServiceNow was connected:
    email: [email protected]
    problem description: Can't log in to my email
    title: Problem with email
    priority: low
Your input ->  thanks. Can i check the status of my other tickets?
    Would you like to use the last email address you used, [email protected]?
Your input ->  Yes please
    Since ServiceNow isn't connected, I'm making this up!
    The most recent incident for [email protected] is currently awaiting triage

With localmode=false:

With a Service Now instance connected, it will check if the email address is in the instance database and provide an incident number for the final response:

Your input ->  help me reset my password
    What is your email address?
Your input ->  [email protected]
    Sorry, "[email protected]" isn't in our incident management system. Please try again.
    What is your email address?
Your input ->  [email protected]
    ? What is the priority of this issue?
Your input -> 3: high (/inform{"priority":"high"})
    What is the problem description for the issue?
Your input ->  Password stuck in a loop
    ? Should I open an incident with the following details?
    email: [email protected]
    problem description: Password stuck in a loop
    title: Problem resetting password
    priority: high
Your input ->  1: Yes (/affirm)
    Successfully opened up incident INC0010008 for you.  Someone will reach out soon.
Your input ->  Can I check the status of my tickets?
    Would you like to use the last email address you used, [email protected]?
Your input ->  Yes please
    Incident INC0010002: "Email Log in problem", opened on 2020-05-21 09:57:06 is currently in progress
    Incident INC0010008: "Problem resetting password", opened on 2020-05-21 12:12:49 is currently awaiting triage
Your input ->  thanks
    You're welcome!

Handoff

This bot includes a simple skill for handing off the conversation to another bot or a human. This demo relies on this fork of chatroom to work, however you could implement similar behaviour in another channel and then use that instead. See the chatroom README for more details on channel-side configuration.

Using the default set up, the handoff skill enables this kind of conversation with two bots:

Try it out

The simplest way to use the handoff feature is to do the following:

  1. Clone chatroom and Financial-Demo alongside this repo
  2. In the chatroom repo, install the dependencies:
yarn install
  1. In the chatroom repo, build and serve chatroom:
yarn build
yarn serve
  1. In the Financial-Demo repo, install the dependencies and train a model (see the Financial-Demo README)
  2. In the Helpdesk-Assistant repo (i.e. this repo), run the rasa server and action server at the default ports (shown here for clarity) In one terminal window:
    rasa run --enable-api --cors "*" --port 5005 --debug
    In another terminal window:
    rasa run actions --port 5055 --debug
  3. In the Financial-Demo repo, run the rasa server and action server at the non-default ports shown below In one terminal window:
    rasa run --enable-api --cors "*" --port 5006 --debug
    In another terminal window:
    rasa run actions --port 5056 --debug
  4. Open chatroom_handoff.html in a browser to see handoff in action

How it works

Using chatroom, the general approach is as follows:

  1. User asks original bot for a handoff.
  2. The original bot handles the request and eventually sends a message with the following custom json payload:
        {
            "handoff_host": "<url of handoff host endpoint>",
            "title": "<title for bot/channel handed off to>"
            }
    
    This message is not displayed in the Chatroom window.
  3. Chatroom switches the host to the specified handoff_host
  4. The original bot no longer receives any messages.
  5. The handoff host receives the message /handoff{"from_host":"<original bot url">}
  6. The handoff host should be configured to respond to this message with something like, "Hi, I'm , how can I help you??"
  7. The handoff host can send a message in the same format as specified above to hand back to the original bot. In this case the same pattern repeats, but with the roles reversed. It could also hand off to yet another bot/human.

Bot-side configuration

The "try it out" section doesn't require any further configuration; this section is for those who want to change or further understand the set up.

For this demo, the user can ask for a human, but they'll be offered a bot (or bots) instead, so that the conversation looks like this:

For handoff to work, you need at least one "handoff_host". You can specify any number of handoff hosts in the file actions/hanodff_config.yml.

handoff_hosts:
    financial_demo:
      title: "Financial Demo"
      url: "http://localhost:5006"
    ## you can add more handoff hosts to this list e.g.
    # moodbot:
    #   title: "MoodBot"
    #   url: "http://localhost:5007"

Handoff hosts can be other locally running rasa bots, or anything that serves responses in the format that chatroom accepts. If a handoff host is not a rasa bot, you will of course want to update the response text to tell the user who/what they are being handed off to.

The Financial-Demo bot has been set up to handle handoff in exactly the same way as Helpdesk-Assistant, so the simplest way to see handoff in action is to clone Financial-Demo alongside this repo.

If you list other locally running bots as handoff hosts, make sure the ports on which the various rasa servers & action servers are running do not conflict with each other.

Testing the bot

You can test the bot on the test conversations by running rasa test. This will run end-to-end testing on the conversations in tests/conversation_tests.md.

Rasa X Deployment

To deploy helpdesk-assistant, it is highly recommended to make use of the one line deploy script for Rasa X. As part of the deployment, you'll need to set up git integration to pull in your data and configurations, and build or pull an action server image.

Action Server Image

You will need to have docker installed in order to build the action server image. If you haven't made any changes to the action code, you can also use the public image on Dockerhub instead of building it yourself.

See the Dockerfile for what is included in the action server image,

To build the image:

docker build . -t <name of your custom image>:<tag of your custom image>

To test the container locally, you can then run the action server container with:

docker run -p 5055:5055 <name of your custom image>:<tag of your custom image>

Once you have confirmed that the container works as it should, you can push the container image to a registry with docker push

It is recommended to use anautomated CI/CD process to keep your action server up to date in a production environment.

Notes on Chatroom

If you want to try the transfer to another bot feature, you'll need to use Chatroom. As of this writing, the main Scalable Minds chatroom project has not included this feature so you will need to build from a fork. The following docker commands will build an image from the adapted Chatroom and run it.

docker build -t chatroom -f Dockerfile.chatroom .
docker run --name chatroom -p 8080:8080 -d chatroom

From the docker-compose.yml below, you can start chatroom with docker-compose up -d

Here's an example docker-compose.yml for this image. Note that the initial Rasa endpoint URL is hard coded in chatroom_handoff.html; to use your locally running bot, point it to http://localhost:5005.

version: "3.4"

services:
  chatroom:
    image: chatroom
    build:
      context: ./
      dockerfile: Dockerfile.chatroom
    ports:
      - "8080:8080"
    command: [ "yarn", "serve" ]

More Repositories

1

rasa

๐Ÿ’ฌ Open source machine learning framework to automate text- and voice-based conversations: NLU, dialogue management, connect to Slack, Facebook, and more - Create chatbots and voice assistants
Python
18,586
star
2

rasa_core

Rasa Core is now part of the Rasa repo: An open source machine learning framework to automate text-and voice-based conversations
Python
2,329
star
3

rasa-demo

๐Ÿฏ Sara - the Rasa Demo Bot: An example of a contextual AI assistant built with the open source Rasa Stack
Python
929
star
4

financial-demo

A demo for a financial services bot
Python
308
star
5

rasalit

Visualizations and helpers to improve and debug machine learning models for Rasa Open Source
Jupyter Notebook
305
star
6

rasa-sdk

SDK for the development of custom actions for Rasa
Python
291
star
7

NLU-training-data

Crowd sourced training data for Rasa NLU models
Python
196
star
8

rasa-nlu-examples

This repository contains examples of custom components for educational purposes.
Python
190
star
9

rasa-voice-interface

๐ŸŽค A simple web interface for building voice assistants with Rasa
Vue
168
star
10

algorithm-whiteboard-resources

this is where we share notebooks/projects used in your youtube channel
Jupyter Notebook
146
star
11

rasa-masterclass

Data and code files for specific Rasa Masterclass episodes
Jupyter Notebook
139
star
12

medicare_locator

๐ŸฅMedicare Locator - Open source starter pack for developers to build contextual chatbots and AI assistants in healthcare
Python
138
star
13

tutorial-knowledge-base

Integrating Rasa with a knowledge base to encode domain knowledge and resolve entities
Python
122
star
14

rasa-x-helm

Rasa Enterprise Helm chart for deploying on Kubernetes (K8s) and OpenShift.
Go
77
star
15

paraphraser

Tool to generate paraphrases of sentences in many languages.
Python
74
star
16

rasa-x-demo

Demo app for running a bot with Rasa Enterprise
Python
69
star
17

conversational-ai-workshop-18

Example showing generalisation
Jupyter Notebook
69
star
18

DIET-paper

Source code to reproduce results of our paper "DIET: Lightweight Language Understanding for Dialogue Systems"
Python
60
star
19

rasa-for-beginners

Rasa for Beginners
Python
57
star
20

STAR

Python
55
star
21

rasa_lookup_demo

Improving entity extraction from text using the lookup table feature in rasa_nlu
Python
52
star
22

tutorial-tf-pipeline

Handling multiple intents using Rasa NLU Tensorflow pipeline
51
star
23

rasa-2.x-form-examples

This repository contains a few simple projects with forms.
Python
48
star
24

kb-demo-chatgpt

Python
46
star
25

nlu-hyperopt

Find the best hyperparameters for your Rasa NLU model
Python
46
star
26

rasa-calm-demo

Python
43
star
27

carbon-bot

Python
42
star
28

breakoutbot

A text based adventure game built with Rasa.
Python
41
star
29

TED-paper

Python
39
star
30

rasa-action-server-gha

A GitHub Action that simplifies using Rasa Actions and helps to prepare a Docker image with custom actions.
Dockerfile
39
star
31

retail-demo

Rasa's retail starter pack
Python
38
star
32

pokedex-demo

Rasa Demo for a digital assistant for pokemon
Python
35
star
33

tutorial-rasa-google-assistant

This repository contains the code of the tutorial 'Going beyond โ€˜Hey Googleโ€™: building a Rasa-powered Google Assistant'
Python
35
star
34

rasa-train-test-gha

A GitHub action to run easily rasa train and rasa test in the CIs.
Python
34
star
35

taipo

Experiments for data quality in Rasa.
Python
34
star
36

rasa-workshop-pydata-berlin

Jupyter Notebook
33
star
37

helm-charts

Helm charts for Rasa products
Smarty
32
star
38

conversational-ai-course-3.x

Containers code for the learning center course.
Python
29
star
39

rasa-workshop

A repository which contains the material for Rasa workshops
Jupyter Notebook
27
star
40

rasa-3.x-form-examples

This repository contains a few simple projects with forms.
Python
27
star
41

insurance-demo

Building a bot to handle general tasks for insurance.
Python
22
star
42

wellness-check-bot

A simple Rasa assistant that uses forms to conduct a daily health survey
Python
21
star
43

tutorial-rasa-alexa

Sample code for a Rasa virtual assistant with an Alexa connector.
Python
19
star
44

workshop-rasax

Python
18
star
45

rasactl

rasactl deploys Rasa X / Enterprise on your local or remote Kubernetes cluster and manages Rasa X / Enterprise deployments.
Go
15
star
46

tod-in-context-learning

Python
15
star
47

rasa-action-examples

A place to host demos for custom actions.
Python
14
star
48

forms_bot

bot which uses forms to do hotel and restaurant booking task
Python
13
star
49

how-to-rasa

Python
13
star
50

live-gdrive-demo

Starter pack for the Rasa Stack
Python
13
star
51

starter-pack-intentless-policy

Python
13
star
52

REI

Rasa Ephermal Installer
Shell
12
star
53

rasa-workshop-pydata-dc

This repository contains the code of the Rasa workshop at PyData DC 2018
Jupyter Notebook
12
star
54

rasa-workshop-pydata-nyc

This repository contains the code of the Rasa workshop at PyData NYC 2018
Jupyter Notebook
12
star
55

awesome-rasa

A list of Rasa resources curated by Rasa and the community.
11
star
56

rasa-custom-spelling-featurizer

This repo contains a tutorial on how to write your own spelling featurizer.
Python
11
star
57

tutorial-migrating-dialogflow-to-rasa

This repository contains the code of the assistant used to demonstrate the migration from DialogFlow to Rasa
Python
11
star
58

spaCy-integration-demo

Python
10
star
59

rasa-3.x-component-examples

A basic Rasa project with Custom Components
Python
10
star
60

livestream-tf-pipeline

Code of the Rasa Twitch livestream on building bots with multi-intents using Rasa NLU TensorFlow pipeline
Python
9
star
61

rasa_stack

A PyPI package which includes Rasa Core and Rasa NLU
Python
8
star
62

rasa-examples

Repository with small Rasa examples.
Python
8
star
63

rasa-custom-fasttext

This repo contains a tutorial on how to make a fasttext featurizer
Python
5
star
64

nlu-and-jupyter

Demonstration of Rasa NLU from Jupyter Lab
Jupyter Notebook
5
star
65

stroopbot

A demonstration of a custom action
Python
4
star
66

rasa-ted-demo

This repo contains a project shows why TED works.
Python
4
star
67

botsociety-py-client

A python client to connect to the Botsociety API
Python
4
star
68

OpenAI_func_calling

4
star
69

workshop-adv-actions

Java
3
star
70

pizza-rule-demo

A demo of rules, stories, actions and forms
Python
3
star
71

benchmark-lookup-ee

This repository contains code to benchmark lookup table entity extraction.
Python
3
star
72

rasa-custom-printer-component

part of a lesson on how to build custom components
Python
3
star
73

multiwoz-paper

Code to analyse MultiWOz and Google Taskmaster-1 dialogue datasets
Python
3
star
74

rei-vm-terraform-example

Example terraform code for creating a VM that is ready for REI installation
Shell
3
star
75

deployment-workshop-bot-2

Python
2
star
76

HandsOn_with_rasa

Python
2
star
77

frontend-coding-test

JavaScript
2
star
78

Hands-on-with-Rasa-2

Python
2
star
79

time-taken-experiment

Some experiments that track how long training might take.
Python
2
star
80

contributors

2
star
81

deploy-tags

TypeScript
2
star
82

deployment-workshop-bot-1

Python
2
star
83

rasa-nlu-eval-compare-gha

A GitHub Action that compares results of multiple Rasa NLU evaluation results and writes the output to an HTML table
Python
2
star
84

calm-guide-code

Python
2
star
85

golastmile.github.io

1
star
86

test-bot

Basic bot used as part of testing Rasa X
Python
1
star
87

rasa-2.0-user-tests-rules

Task for the user tests for rules as part of Rasa Open Source 2.0.
Python
1
star
88

frontend-test

Example Entity annotator (Mock repository)
JavaScript
1
star
89

workshop-rasax-short

Short version of Rasa X workshop
Python
1
star
90

financial-spaces-bot

Python
1
star
91

bart-examples

Repo with example bots on different branches
1
star
92

chatbotsummit-workshop

Python
1
star
93

deployment-workshop-bot-3

Bot for the exam project of the deployment workshop
Python
1
star
94

csm-onboarding

Repo to manage gitpod instances for CSM onboarding
Python
1
star
95

homebrew-rasactl

Homebrew Formula for rasactl
Ruby
1
star
96

webkit-voice-demo

This is a project that shows how to integrate webkit voice with Rasa.
HTML
1
star
97

tourist-agency-calm

Tourist agency example with CALM approach
Python
1
star