Commit 11adf58a by Ravi Teja

intial rasa code commit for staffing bot

parent 598343f8
Covid-19 Chatbot develped using RASA
No preview for this file type
File mode changed
No preview for this file type
No preview for this file type
from typing import Any, Text, Dict, List,Union, Optional
from rasa_sdk.events import SlotSet
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher
from rasa_sdk.forms import FormAction, Action
from rasa_sdk.events import SlotSet
import re
from twilio.rest import Client
account_sid = "ACc460d692e5a467c60b352714b1416140"
auth_token = "bf2a890f36e3329b52d0516a14097623"
client = Client(account_sid, auth_token)
regex_phone = r"(\d{3}[-\.\s]??\d{3}[-\.\s]??\d{4}\d?|\(\d{3}\)\s*[-]?\d{3}[-\.\s]??\d{4}|\d{3}[-\.\s]??\d{4}|[+]?\d[-][(]?\d{3}[)]?[-]\d{3}[-]\d{4})"
class ActionSendSms(Action):
def name(self) -> Text:
return "action_send_sms"
async def run(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any],
) -> List[Dict[Text, Any]]:
for each_event in tracker.events[::-1]:
if each_event['event'] == 'user':
#print(tracker.events[-1]['parse_data']['intent']['name'])
if each_event['parse_data']['intent']['name'] == "send_sms":
querytext = each_event['text']
intentname = "send_sms"
confidence = each_event['parse_data']['intent']['confidence']
print(querytext)
pattern = re.compile(regex_phone)
data = pattern.search(querytext)
if data is not None:
phone_no = data.group()
client.messages.create(
to = phone_no,
from_= "+19169995105",
body= "Hi. This is VERA from V-Soft consulting. We may have great job opportunities based on your profile. Are you interested ? "
)
dispatcher.utter_template('utter_sms', tracker)
return []
class Primary_information(FormAction):
print('in Primary_information')
def name(self) -> Text:
return "primary_information_form"
@staticmethod
def required_slots(tracker: Tracker) -> List[Text]:
intent = tracker.latest_message.get("intent", {}).get("name")
conf = tracker.latest_message.get("intent", {}).get("confidence")
print('querytext',tracker.slots["querytext"])
print('intent',intent)
print('conf',conf)
#if intent == "affirm" :
if intent != "deny" :
print("IN from deny")
#tracker.slots["querytext"] = "no"
return["intentname","confidence","querytext","askques", "email", "mobilenumber", "company","experience", "skills","availabletime"]
else:
print("IN from deny1")
tracker.slots["querytext"] = "no"
return["availabletime"]
def validate_querytext(self,value:Text,dispatcher: CollectingDispatcher,tracker: Tracker,domain: Dict[Text, Any],) -> Dict[Text, Any]:
print("------------------------")
#print(tracker.events)
for each_event in tracker.events[::-1]:
print('1111111')
print("each_event['event']", each_event['event'])
if each_event['event'] == 'user':
print('2222')
print('intent name', tracker.events[-1]['parse_data']['intent']['name'])
if each_event['parse_data']['intent']['name'] == "affirm":
print('33333')
querytext = each_event['text']
intentname = "affirm"
confidence = each_event['parse_data']['intent']['confidence']
print(querytext)
break
print('44444444')
return {"querytext":querytext,"intentname":intentname,"confidence":confidence}
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
return {
"askques": self.from_text(),
"email": self.from_text(),
"mobilenumber": self.from_text(),
"company": self.from_text(),
"experience": self.from_text(),
"skills": self.from_text(),
"availabletime": self.from_text()
}
def submit(
self,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) ->List[Dict]:
if tracker.get_slot("querytext") != "no":
return []
else:
dispatcher.utter_template('utter_slots_datetime', tracker)
return []
class ResetSlot(Action):
def name(self):
return "action_reset"
def run(self, dispatcher, tracker, domain):
return [SlotSet("email", None), SlotSet("querytext","empty"),SlotSet("intentname","empty"),SlotSet("confidence",None),SlotSet("mobilenumber",None),SlotSet("experience",None), SlotSet("skills",None), SlotSet("askques",None),SlotSet("availabletime",None)]
#SlotSet("copeup","empty"),SlotSet("sources","empty"), SlotSet("concern","empty"),SlotSet("pressingconcerns","empty"),SlotSet("items","empty"),SlotSet("purchase","empty"),SlotSet("fmembers","empty"),SlotSet("socialmedia","empty"),SlotSet("assistance","empty"),SlotSet("mobilenumber","empty"),
File mode changed
# Configuration for Rasa NLU.
# https://rasa.com/docs/rasa/nlu/components/
language: en
pipeline:
- name: "WhitespaceTokenizer"
- name: "CountVectorsFeaturizer"
- name: "EmbeddingIntentClassifier"
case_sensitive: false
epochs: 400
- name: "CRFEntityExtractor"
case_sensitive: false
# Configuration for Rasa Core.
# https://rasa.com/docs/rasa/core/policies/
policies:
- name: MemoizationPolicy
- name: KerasPolicy
batch_size : 100
epochs : 300
validation_split : 0.2
- name: MappingPolicy
- name: EmbeddingPolicy
- name: FormPolicy
- name: "FallbackPolicy"
nlu_threshold: 0.3
core_threshold: 0.3
fallback_action_name: "action_default_fallback"
# This file contains the credentials for the voice & chat platforms
# which your bot is using.
# https://rasa.com/docs/rasa/user-guide/messaging-and-voice-channels/
rest:
# # you don't need to provide anything here - this channel doesn't
# # require any credentials
#facebook:
# verify: "<verify>"
# secret: "<your secret>"
# page-access-token: "<your page access token>"
#slack:
# slack_token: "<your slack token>"
# slack_channel: "<the slack channel>"
socketio:
user_message_evt: user_uttered
bot_message_evt: bot_uttered
session_persistence: true
#mattermost:
# url: "https://<mattermost instance>/api/v4"
# team: "<mattermost team>"
# user: "<bot username>"
# pw: "<bot token>"
# webhook_url: "<callback URL>"
rasa:
url: "http://0.0.0.0:5002/api"
twilio:
account_sid: "ACc460d692e5a467c60b352714b1416140"
auth_token: "bf2a890f36e3329b52d0516a14097623"
twilio_number: "+19169995105"
## intent:affirm
- correct
- ye
- uh yes
- let's do it
- yeah
- uh yes
- um yes
- yes knocking
- that's correct
- yes yes
- right
- yea
- yes
- yes right
- yes and i dont care
- right on
- i love that
- sure
- yes, please go ahead
## intent:deny
- no
- no need
- no thanks
- no thank you
- uh no
- breath no
- i don't want it
- no, thank you
## intent:send_sms
- send 19169995105
- send sms 19169995105
- send sms to 19169995105
- 19169995105 send sms
- sms for 19169995105
- 19169995105
- sms sms 19169995105
- sms 19169995105
- send 19169995105 sms
- 19169995105 sms
- sms to 19169995105
## intent:primary_information
- primary info
- primary infomation
- primary infomation details
- grab some information on primary infomation
- about primary infomation
- primary infomation gathering
- information related to primary
- get the details of primary info
- informaiton related to primary
- primary infomation for me
- information on primary infomation
- details of primary infomation
## intent:stop
- please stop it
- discard
- discard that please
- just stop it
- cancel it
- quit now
- exit immediately
- not helped just stop
- why don't you stop
- cancel
- exit
- quit
- halt
- abort
- stop
## intent:welcome
- welcome
- welcome to Vera
- help
- help me
- how can you help me
- can you please help me
- please help
- can you help me to proceed further
- help please
- welcome screen
- start welcome
- welcome help
- welcome buttons
- welcome screen
- help screen
- help to move further
- help please
## intent:greet
- good evening
- hello
- hi
- hai
- hey there
- hey
- good morning
- hey hello
- hi hi
- hi vera
- hello vera
- hey, hi how are you
- hello hi
- hi hello
- good morning, hi
- good evening, hello
- good afternoon, hi
## intent:goodbye
- see you around
- bye
- goodbye
- see you later
- thank you
- thankyou
- thanks
- thank you very much
- thanks a lot
- thanks for your information
- bye bye
- good bye
- see you later, bye
- thanks, bye
- thanks a lot, bye
- thank you bye
- bye
- bye
- thanks alot, bye
- see you later, bye
- bye
- thanks for infomation, bye
## say primary_information
* affirm
- primary_information_form
- form{"name": "primary_information_form"}
- form{"name": null}
- utter_slots_primary_information
- action_reset
> check_primary_information
## say primary_information1
> check_primary_information
* affirm
- primary_information_form
- form{"name": "primary_information_form"}
- form{"name": null}
- utter_slots_primary_information
- action_reset
## say stop
* stop
- utter_stop
> check_stop
## say stop1
> check_stop
* stop
- utter_stop
## happy greet
* greet
- utter_greet
> check_greet
## happy greet1
> check_greet
* greet
- utter_greet
## happy wecome
* welcome
- utter_welcome
> check_welcome
## happy welcome1
> check_welcome
* welcome
- utter_welcome
## say goodbye
* goodbye
- utter_goodbye
> check_goodbye
## say goodbye1
> check_goodbye
* goodbye
- utter_goodbye
## story of greet and bye
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* greet
- utter_greet
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
* goodbye
- utter_goodbye
version: '3.0'
services:
rasa_test:
image: eswar/rasa:latest
#image: rasa/151:latest
#image: eswar/rasa1:latest
networks: ['rasa-network_test']
ports:
- "12921:5005"
depends_on:
- action_server_test
volumes:
- "./:/app"
command:
- run
- --cors
- "*"
- --debug
- --log-file
- logger.log
action_server_test:
image: twilio/sms:latest
#image: dateutil/rasa:latest
#image: rasa/rasa-sdk:1.6.0
#image: rasa/rasa-sdk:latest
#image: eswar/rasa:latest
#image: rasa/sdk:latest
#image: eswar/rasa1:latest
networks: ['rasa-network_test']
ports:
- "5055:5055"
volumes:
- "./actions:/app/actions"
networks: {rasa-network_test: {}}
FROM rasa/rasa-sdk:1.6.0
# To install packages from PyPI
#RUN pip install --no-cache-dir calendar #<A_REQUIRED_PACKAGE_ON_PYPI>
RUN pip install --no-cache-dir twilio
actions:
- action_send_sms
- utter_ask_mobilenumber
- utter_ask_email
- utter_ask_experience
- utter_ask_skills
- utter_slots_primary_information
- utter_stop
- action_reset
- utter_goodbye
- utter_greet
- utter_welcome
- utter_deny
- utter_ask_company
- utter_ask_askques
- utter_ask_availabletime
- utter_slots_datetime
entities:
- askques
- availabletime
- confidence
- intentname
- querytext
- email
- mobilenumber
- experience
- skills
- company
forms:
- primary_information_form
intents:
- affirm
- deny:
triggers: utter_deny
- send_sms:
triggers: action_send_sms
- primary_information:
use_entities: []
- welcome
- goodbye
- greet
- stop
slots:
askques:
type: unfeaturized
email:
type: unfeaturized
mobilenumber:
type: unfeaturized
company:
type: unfeaturized
experience:
type: unfeaturized
skills:
type: unfeaturized
availabletime:
type: unfeaturized
confidence:
initial_value: empty
type: unfeaturized
intentname:
initial_value: empty
type: unfeaturized
querytext:
initial_value: empty
type: unfeaturized
requested_slot:
type: unfeaturized
templates:
utter_slots_datetime:
- custom:
availabletime: '{availabletime}'
response: "Thank you"
utter_ask_askques:
- custom:
text: "To see how we can help you most, we would like to ask you few questions about your career. Is it ok? reply with yes/no"
utter_ask_availabletime:
- custom:
text: "could you please let us know a time and date so one of our recruiters can give you a call?"
utter_deny:
- custom:
text: "0"
response: "Thankyou. It looks like you are not interested in job opportunity now but we will save your resume and contact you if your resume matches a different job postings."
utter_sms:
- custom:
text: "send sms successfully"
utter_ask_company:
- custom:
text: "what is the curent company you are working for ?"
utter_ask_mobilenumber:
- custom:
text: "Can you please update your mobile number ?"
utter_ask_email:
- custom:
text: "Can you please update your email address ?"
utter_ask_experience:
- custom:
text: "What is your current job title ? "
utter_ask_skills:
- custom:
text: "Can you provide your primary skills ?"
utter_slots_primary_information:
- custom:
email: '{email}'
mobilenumber: '{mobilenumber}'
company: '{company}'
experience: '{experience}'
skills: '{skills}'
response: "Thank you."
text: "1"
availabletime: '{availabletime}'
utter_stop:
- custom:
text: "STOP"
utter_default:
- custom:
text: "Sorry. I didn't get. Can you please rephrase it."
utter_goodbye:
- custom:
text: "Bye"
utter_greet:
- custom:
text: "Hi, I am VERA virtual Assistant"
utter_welcome:
- custom:
text: "Hi, I am VERA virtual Assistant"
# This file contains the different endpoints your bot can use.
# Server where the models are pulled from.
# https://rasa.com/docs/rasa/user-guide/running-the-server/#fetching-models-from-a-server/
#models:
# url: http://my-server.com/models/default_core@latest
# wait_time_between_pulls: 10 # [optional](default: 100)
# Server which runs your custom actions.
# https://rasa.com/docs/rasa/core/actions/#custom-actions/
action_endpoint:
#url: "http://action_server_test:5055/webhook"
url: "http://localhost:5055/webhook"
# Tracker store which is used to store the conversations.
# By default the conversations are stored in memory.
# https://rasa.com/docs/rasa/api/tracker-stores/
#tracker_store:
# type: redis
# url: <host of the redis instance, e.g. localhost>
# port: <port of your redis instance, usually 6379>
# db: <number of your database within redis, e.g. 0>
# password: <password used for authentication>
# use_ssl: <whether or not the communication is encrypted, default false>
#tracker_store:
# type: mongod
# url: <url to your mongo instance, e.g. mongodb://localhost:27017>
# db: <name of the db within your mongo instance, e.g. rasa>
# username: <username used for authentication>
# password: <password used for authentication>
# Event broker which all conversation events should be streamed to.
# https://rasa.com/docs/rasa/api/event-brokers/
#event_broker:
# url: localhost
# username: username
# password: password
# queue: queue
git init
1400 git remote add origin https://gitlab.vsoftconsulting.com/ml_workspace/vera.git
1401 git fetch --all
1402 ls
1403 git branch
1404 git checkout rasa_test
1405 git branch
1406 git pull
git reset --hard
<!DOCTYPE html>
<html>
<head>
<title>chat widget</title>
</head>
<body>
<div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-latest.js"></script>
<script>
WebChat.default.init({
selector: "#webchat",
customData: {"userId": "123"},
socketUrl: "http://localhost:5005",
socketPath: "/socket.io/",
title: "VERA",
inputTextFieldHint: "Type a message...",
connectingText: "Waiting for server...",
hideWhenNotConnected: true,
fullScreenMode: true,
showFullScreenButton: true,
profileAvatar: "profile.jpeg",
openLauncherImage: 'myCustomOpenImage.png',
closeLauncherImage: 'myCustomCloseImage.png',
displayUnreadCount: true, // --> [view](./assets/unread_count_pastille.png)
showMessageDate: true,
tooltipPayload: '/get_tooltip',
tooltipDelay: 1000,
customMessageDelay: (message) => {
if (message.length > 100) return 2000;
return 1000;
},
params: {
images: {
dims: {
width: 300,
height: 200,
}
},
storage: "local"
},
})
</script>
</body>
</html>
This diff could not be displayed because it is too large.
No preview for this file type
digraph {
0 [class="start active", fillcolor=green, fontsize=12, label=START, style=filled];
"-1" [class=end, fillcolor=red, fontsize=12, label=END, style=filled];
1 [class=active, fontsize=12, label=primary_information_form];
2 [class=active, fontsize=12, label=utter_slots_primary_information];
3 [class=active, fontsize=12, label=action_reset];
7 [class="", fontsize=12, label=utter_stop];
"-3" [class=ellipsis, label="..."];
8 [class="", fontsize=12, label=utter_greet];
9 [class="", fontsize=12, label=utter_welcome];
"-5" [class=ellipsis, label="..."];
10 [class="", fontsize=12, label=utter_goodbye];
"-6" [class=ellipsis, label="..."];
"-7" [class=ellipsis, label="..."];
21 [class=active, fontsize=12, label=action_default_fallback];
22 [class="intent dashed active", label=" ? ", shape=rect];
23 [class="intent active", fillcolor=lightblue, label=yes, shape=rect, style=filled];
24 [class=intent, fillcolor=lightblue, label="/stop", shape=rect, style=filled];
25 [class=intent, fillcolor=lightblue, label="/greet", shape=rect, style=filled];
26 [class=intent, fillcolor=lightblue, label="/welcome", shape=rect, style=filled];
27 [class=intent, fillcolor=lightblue, label="/goodbye", shape=rect, style=filled];
28 [class="intent active", fillcolor=lightblue, label=yes, shape=rect, style=filled];
29 [class="intent active", fillcolor=lightblue, label="sai@gmail.com", shape=rect, style=filled];
0 -> 23 [class=active, key=0];
0 -> 24 [class="", key=0];
0 -> 25 [class="", key=0];
0 -> 26 [class="", key=0];
0 -> 27 [class="", key=0];
1 -> 2 [class=active, key=NONE, label=""];
2 -> 3 [class=active, key=NONE, label=""];
3 -> "-1" [class="", key=NONE, label=""];
3 -> 28 [class=active, key=0];
3 -> 29 [class=active, key=0];
7 -> "-3" [class="", key=NONE, label=""];
8 -> "-7" [class="", key=NONE, label=""];
9 -> "-5" [class="", key=NONE, label=""];
10 -> "-6" [class="", key=NONE, label=""];
21 -> 22 [class=active, key=NONE, label=""];
23 -> 1 [class=active, key=0];
24 -> 7 [class="", key=0];
25 -> 8 [class="", key=0];
26 -> 9 [class="", key=0];
27 -> 10 [class="", key=0];
28 -> 1 [class=active, key=0];
29 -> 21 [class=active, key=0];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment