Skip to content
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit 0d289a8

Browse files
author
jubin
committed
lead generation bot
1 parent 1d9a921 commit 0d289a8

File tree

8 files changed

+416
-0
lines changed

8 files changed

+416
-0
lines changed

02_leadbot/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Lead generation Chatbot Template

02_leadbot/compressed.zip

4.18 KB
Binary file not shown.

02_leadbot/src/actions.py

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
from typing import Dict, Text, Any, List, Union, Optional
2+
3+
from rasa_sdk import Tracker
4+
from rasa_sdk.executor import CollectingDispatcher
5+
from rasa_sdk.forms import FormAction
6+
7+
8+
class LeadFormFirstPart(FormAction):
9+
"""Example of a custom form action"""
10+
11+
def name(self) -> Text:
12+
"""Unique identifier of the form"""
13+
14+
return "lead_form_p1"
15+
16+
@staticmethod
17+
def required_slots(tracker: Tracker) -> List[Text]:
18+
"""A list of required slots that the form has to fill"""
19+
return ["requirement", "mockup"]
20+
21+
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
22+
"""A dictionary to map required slots to
23+
- an extracted entity
24+
- intent: value pairs
25+
- a whole message
26+
or a list of them, where a first match will be picked"""
27+
return {
28+
"requirement": [
29+
self.from_text(),
30+
],
31+
"mockup": [
32+
self.from_text(),
33+
],
34+
}
35+
36+
def submit(
37+
self,
38+
dispatcher: CollectingDispatcher,
39+
tracker: Tracker,
40+
domain: Dict[Text, Any],
41+
) -> List[Dict]:
42+
"""Define what the form has to do
43+
after all required slots are filled"""
44+
45+
# utter submit template
46+
dispatcher.utter_template("utter_urlAvailable", tracker)
47+
return []
48+
49+
50+
class LeadFormSecondPart(FormAction):
51+
"""Example of a custom form action"""
52+
53+
def name(self) -> Text:
54+
"""Unique identifier of the form"""
55+
56+
return "lead_form_p2"
57+
58+
@staticmethod
59+
def required_slots(tracker: Tracker) -> List[Text]:
60+
"""A list of required slots that the form has to fill"""
61+
return ["url"]
62+
63+
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
64+
"""A dictionary to map required slots to
65+
- an extracted entity
66+
- intent: value pairs
67+
- a whole message
68+
or a list of them, where a first match will be picked"""
69+
return {
70+
"url": [
71+
self.from_text(),
72+
],
73+
}
74+
75+
def submit(
76+
self,
77+
dispatcher: CollectingDispatcher,
78+
tracker: Tracker,
79+
domain: Dict[Text, Any],
80+
) -> List[Dict]:
81+
"""Define what the form has to do
82+
after all required slots are filled"""
83+
84+
return []
85+
86+
87+
class LeadFormThirdPart(FormAction):
88+
"""Example of a custom form action"""
89+
90+
def name(self) -> Text:
91+
"""Unique identifier of the form"""
92+
93+
return "lead_form_p3"
94+
95+
@staticmethod
96+
def required_slots(tracker: Tracker) -> List[Text]:
97+
"""A list of required slots that the form has to fill"""
98+
return ["timeline", "budget", "name", "email", "phone"]
99+
100+
def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
101+
"""A dictionary to map required slots to
102+
- an extracted entity
103+
- intent: value pairs
104+
- a whole message
105+
or a list of them, where a first match will be picked"""
106+
return {
107+
"timeline": [
108+
self.from_text(),
109+
],
110+
"budget": [
111+
self.from_text(),
112+
],
113+
"name": [
114+
self.from_text(),
115+
],
116+
"email": [
117+
self.from_text(),
118+
],
119+
"phone": [
120+
self.from_text(),
121+
],
122+
}
123+
124+
def submit(
125+
self,
126+
dispatcher: CollectingDispatcher,
127+
tracker: Tracker,
128+
domain: Dict[Text, Any],
129+
) -> List[Dict]:
130+
"""Define what the form has to do
131+
after all required slots are filled"""
132+
133+
# utter submit template
134+
dispatcher.utter_template("utter_lead_q2", tracker)
135+
return []

02_leadbot/src/config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Configuration for Rasa NLU.
2+
# https://rasa.com/docs/rasa/nlu/components/
3+
language: en
4+
pipeline: supervised_embeddings
5+
6+
# Configuration for Rasa Core.
7+
# https://rasa.com/docs/rasa/core/policies/
8+
policies:
9+
- name: FormPolicy
10+
- name: MemoizationPolicy
11+
- name: KerasPolicy
12+
- name: MappingPolicy

02_leadbot/src/data/nlu.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## intent:greet
2+
- hey
3+
- hello
4+
- hi
5+
- good morning
6+
- good evening
7+
- hey there
8+
9+
## intent:accept
10+
- yes
11+
- right
12+
- ok
13+
- okay
14+
- sure
15+
- fine
16+
- it's ok
17+
- it is okay
18+
- of cause
19+
- ofcause
20+
21+
## intent:reject
22+
- no
23+
- don't
24+
- dont
25+
- do not
26+
- please no
27+
- no please
28+
- never
29+
- don't do
30+
31+
## intent:begin_lead
32+
- begin lead
33+
- Web Application Development
34+
- Mobile App Development
35+
- Chatbot Development
36+
- Frontend Development
37+
- Progessive Web App Development
38+
- AI & Machine Learning

02_leadbot/src/data/stories.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## begin conversation
2+
* greet
3+
- utter_greet
4+
- utter_menu
5+
6+
## combined begin with url
7+
* greet
8+
- utter_greet
9+
- utter_menu
10+
* begin_lead
11+
- utter_lead_q1
12+
- lead_form_p1
13+
- form{"name": "lead_form_p1"}
14+
- form{"name": null}
15+
* accept
16+
- lead_form_p2
17+
- form{"name": "lead_form_p2"}
18+
- form{"name": null}
19+
- lead_form_p3
20+
- form{"name": "lead_form_p3"}
21+
- form{"name": null}
22+
- utter_lead_q3
23+
- utter_lead_q4
24+
- utter_lead_q5
25+
26+
## combined begin without url
27+
* greet
28+
- utter_greet
29+
- utter_menu
30+
* begin_lead
31+
- utter_lead_q1
32+
- lead_form_p1
33+
- form{"name": "lead_form_p1"}
34+
- form{"name": null}
35+
* reject
36+
- lead_form_p3
37+
- form{"name": "lead_form_p3"}
38+
- form{"name": null}
39+
- utter_lead_q3
40+
- utter_lead_q4
41+
- utter_lead_q5

02_leadbot/src/domain.yml

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
intents:
2+
- greet
3+
- accept
4+
- reject
5+
- begin_lead
6+
7+
slots:
8+
requirement:
9+
type: unfeaturized
10+
auto_fill: false
11+
mockup:
12+
type: unfeaturized
13+
auto_fill: false
14+
url:
15+
type: unfeaturized
16+
auto_fill: false
17+
timeline:
18+
type: unfeaturized
19+
auto_fill: false
20+
budget:
21+
type: unfeaturized
22+
auto_fill: false
23+
name:
24+
type: unfeaturized
25+
auto_fill: false
26+
email:
27+
type: unfeaturized
28+
auto_fill: false
29+
phone:
30+
type: unfeaturized
31+
auto_fill: false
32+
33+
actions:
34+
- utter_greet
35+
- utter_menu
36+
- utter_urlAvailable
37+
- utter_lead_q1
38+
- utter_lead_q2
39+
- utter_lead_q3
40+
- utter_lead_q4
41+
- utter_lead_q5
42+
43+
forms:
44+
- lead_form_p1
45+
- lead_form_p2
46+
- lead_form_p3
47+
48+
templates:
49+
utter_greet:
50+
- text: "Hi! I am John from Cedex Technologies LLP. We provide high quality and cost-effective Web, Mobile, Chatbot and Voicebot solutions."
51+
52+
utter_menu:
53+
- text: "What are you looking for today?"
54+
buttons:
55+
- title: "Web Application Development"
56+
payload: "/begin_lead"
57+
- title: "Mobile App Development"
58+
payload: "/begin_lead"
59+
- title: "Chatbot Development"
60+
payload: "/begin_lead"
61+
- title: "Frontend Development"
62+
payload: "/begin_lead"
63+
- title: "Progessive Web App Development"
64+
payload: "/begin_lead"
65+
- title: "AI & Machine Learning"
66+
payload: "/begin_lead"
67+
68+
utter_lead_q1:
69+
- text: "Great. We have developed more than 100+ web applications till date!"
70+
71+
utter_ask_requirement:
72+
- text: "Can you share some brief description of your requirements?"
73+
74+
utter_ask_mockup:
75+
- text: "Alright! \n\nDo you have any of the following ready?"
76+
buttons:
77+
- title: "Wireframes"
78+
payload: "Wireframes"
79+
- title: "Designs"
80+
payload: "Designs"
81+
- title: "RFP or any Document"
82+
payload: "RFP or any Document"
83+
- title: "None"
84+
payload: "None"
85+
86+
utter_urlAvailable:
87+
- text: "Is there any URL that you would like to share for our reference?"
88+
buttons:
89+
- title: "Yes"
90+
payload: "yes"
91+
- title: "No"
92+
payload: "no"
93+
94+
utter_ask_url:
95+
- text: "Could you please share the URL with us?"
96+
97+
utter_ask_timeline:
98+
- text: "When do you plan to enter development with this project?"
99+
buttons:
100+
- title: "Immediately"
101+
payload: "Immediately"
102+
- title: "within a month"
103+
payload: "within a month"
104+
- title: "within the next 3 months"
105+
payload: "within the next 3 months"
106+
- title: "after 3 months"
107+
payload: "after 3 months"
108+
109+
utter_ask_budget:
110+
- text: "Great!\n\nWhat is your earmarked budget for this project?"
111+
buttons:
112+
- title: "Below $5000"
113+
payload: "Below $5000"
114+
- title: "$5000 - $15000"
115+
payload: "$5000 - $15000"
116+
- title: "$15000 - $25000"
117+
payload: "$15000 - $25000"
118+
- title: "$25000 and above"
119+
payload: "$25000 and above"
120+
121+
utter_ask_name:
122+
- text: "Great. May I know your name please?"
123+
124+
utter_ask_email:
125+
- text: "Can you please share your email ID? Trust us, we will never spam!"
126+
127+
utter_ask_phone:
128+
- text: "Can I have your phone number"
129+
130+
utter_lead_q2:
131+
- text: "Thanks for answering all our questions and being this patient. We appreciate it!"
132+
133+
utter_lead_q3:
134+
- text: "Here is your data: \n
135+
- requirement: {requirement}\n
136+
- mockup: {mockup}\n
137+
- url: {url}\n
138+
- timeline: {timeline}\n
139+
- budget: {budget}\n
140+
- name: {name}\n
141+
- email: {email}\n
142+
- phone: {phone}"
143+
144+
utter_lead_q4:
145+
- text: "I will have our Business Experts get in touch with you soon, to make your project a reality!"
146+
147+
utter_lead_q5:
148+
- text: "In the meanwhile for anything, you can contact us at sales@cedextech.com or +91 888 999 9999"

0 commit comments

Comments
 (0)