-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1232fa0
Showing
37 changed files
with
11,153 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[user] | ||
name = Namrata B | ||
email = namratabafna14@gmail.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.formatting.provider": "black" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# RasaChatBot |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import unicode_literals | ||
|
||
from rasa_sdk import Action | ||
from rasa_sdk.events import SlotSet | ||
import pandas as pd | ||
import json | ||
import smtplib | ||
from email.mime.multipart import MIMEMultipart | ||
from email.mime.text import MIMEText | ||
from rasa_sdk.events import AllSlotsReset | ||
|
||
ZomatoData = pd.read_csv("zomato.csv", encoding="cp1252") | ||
ZomatoData = ZomatoData.drop_duplicates().reset_index(drop=True) | ||
WeOperate = [ | ||
"New Delhi", | ||
"Gurgaon", | ||
"Noida", | ||
"Faridabad", | ||
"Allahabad", | ||
"Bhubaneshwar", | ||
"Mangalore", | ||
"Mumbai", | ||
"Ranchi", | ||
"Patna", | ||
"Mysore", | ||
"Aurangabad", | ||
"Amritsar", | ||
"Puducherry", | ||
"Varanasi", | ||
"Nagpur", | ||
"Vadodara", | ||
"Dehradun", | ||
"Vizag", | ||
"Agra", | ||
"Ludhiana", | ||
"Kanpur", | ||
"Lucknow", | ||
"Surat", | ||
"Kochi", | ||
"Indore", | ||
"Ahmedabad", | ||
"Coimbatore", | ||
"Chennai", | ||
"Guwahati", | ||
"Jaipur", | ||
"Hyderabad", | ||
"Bangalore", | ||
"Nashik", | ||
"Pune", | ||
"Kolkata", | ||
"Bhopal", | ||
"Goa", | ||
"Chandigarh", | ||
"Ghaziabad", | ||
"Ooty", | ||
"Gangtok", | ||
"Shimla", | ||
] | ||
|
||
|
||
def RestaurantSearch(City, Cuisine, PriceRange): | ||
|
||
if PriceRange == "LessThan300": | ||
print("PriceRange ", PriceRange) | ||
# Price Range Lesser than Rs. 300 | ||
TEMP = ZomatoData[ | ||
(ZomatoData["Cuisines"].apply(lambda x: Cuisine.lower() in x.lower())) | ||
& (ZomatoData["City"].apply(lambda x: City.lower() in x.lower())) | ||
& ZomatoData["Average Cost for two"].between(0, 299) | ||
] | ||
|
||
elif PriceRange == "Three00To700": | ||
print("PriceRange ", PriceRange) | ||
# Price is between 300 and 700 | ||
TEMP = ZomatoData[ | ||
(ZomatoData["Cuisines"].apply(lambda x: Cuisine.lower() in x.lower())) | ||
& (ZomatoData["City"].apply(lambda x: City.lower() in x.lower())) | ||
& ZomatoData["Average Cost for two"].between(300, 700) | ||
] | ||
elif PriceRange == "MoreThan700": | ||
print("PriceRange ", PriceRange) | ||
# Price is greater than 700 | ||
TEMP = ZomatoData[ | ||
(ZomatoData["Cuisines"].apply(lambda x: Cuisine.lower() in x.lower())) | ||
& (ZomatoData["City"].apply(lambda x: City.lower() in x.lower())) | ||
& (ZomatoData["Average Cost for two"] > 700) | ||
] | ||
else: | ||
# Price is not specified | ||
TEMP = ZomatoData[ | ||
(ZomatoData["Cuisines"].apply(lambda x: Cuisine.lower() in x.lower())) | ||
& (ZomatoData["City"].apply(lambda x: City.lower() in x.lower())) | ||
] | ||
# Sort by Rating | ||
TEMP = TEMP.sort_values("Aggregate rating", ascending=False) | ||
return TEMP[ | ||
["Restaurant Name", "Address", "Average Cost for two", "Aggregate rating"] | ||
] | ||
|
||
|
||
class ActionSearchRestaurants(Action): | ||
def name(self): | ||
return "action_search_restaurants" | ||
|
||
def run(self, dispatcher, tracker, domain): | ||
print("Action Search Restaurant is excecuting..") | ||
loc = tracker.get_slot("location") | ||
|
||
# Check if Zomato operates in specified location | ||
loc_exists = len(ZomatoData[ZomatoData["City"].str.contains(loc)]) > 0 | ||
if loc_exists == False: | ||
print("Location exists ", loc_exists) | ||
dispatcher.utter_message( | ||
"-----Sorry, we don’t operate in this city. Can you please specify some other location" | ||
) | ||
return [SlotSet("location", loc)] | ||
cuisine = tracker.get_slot("cuisine") | ||
price_range = tracker.get_slot("price_range") | ||
results = RestaurantSearch(City=loc, Cuisine=cuisine, PriceRange=price_range) | ||
global response | ||
response = "" | ||
if results.shape[0] == 0: | ||
response = "Sorry! There are no restaurants matching the search criteria" | ||
else: | ||
response = response + f"-----Found {len(results)} restaurants----- \n" | ||
response = response + f"-----Showing Top 10 matching results----- \n" | ||
for restaurant in results.iloc[:10].iterrows(): | ||
restaurant = restaurant[1] | ||
response = ( | ||
response | ||
+ f"{restaurant['Restaurant Name']} in {restaurant['Address']} rated {restaurant['Address']} with avg cost {restaurant['Average Cost for two'] } \n" | ||
+ f"**Rating {restaurant['Aggregate rating']} \n\n" | ||
) | ||
|
||
dispatcher.utter_message("-----" + response) | ||
return [ | ||
SlotSet("location", loc), | ||
SlotSet("cuisine", cuisine), | ||
SlotSet("price_range", price_range), | ||
] | ||
|
||
|
||
class ActionSendMail(Action): | ||
def name(self): | ||
return "action_send_mail" | ||
|
||
def run(self, dispatcher, tracker, domain): | ||
receiver_address = tracker.get_slot("cust_email") | ||
if receiver_address: | ||
print("email ", receiver_address) | ||
try: | ||
print("Mail Content ", response) | ||
mail_content = response | ||
sender_address = "namratabafna14@gmail.com" | ||
sender_pass = "" | ||
print("Setup account") | ||
# Setup the MIME | ||
message = MIMEMultipart() | ||
message["From"] = sender_address | ||
message["To"] = receiver_address | ||
message[ | ||
"Subject" | ||
] = "Here are the details of the top restaurants from Zomato search - Upgrad" # The subject line | ||
# The body and the attachments for the mail | ||
message.attach(MIMEText(mail_content, "plain")) | ||
# Create SMTP session for sending the mail | ||
session = smtplib.SMTP("smtp.gmail.com", 587) # use gmail with port | ||
session.starttls() # enable security | ||
session.login( | ||
sender_address, sender_pass | ||
) # login with mail_id and password | ||
text = message.as_string() | ||
session.sendmail(sender_address, receiver_address, text) | ||
session.quit() | ||
print("Mail sent successfully to - ", receiver_address) | ||
dispatcher.utter_message( | ||
"-----Mail sent successfully to - ", receiver_address | ||
) | ||
except Exception as e: | ||
dispatcher.utter_message( | ||
"-----Failed email sending to - ", receiver_address | ||
) | ||
print("Failed to send an email to ", receiver_address) | ||
print(e) | ||
else: | ||
dispatcher.utter_message("-----You will not receive an email") | ||
return [SlotSet("cust_email", receiver_address)] | ||
|
||
|
||
class ActionSlotReset(Action): | ||
def name(self): | ||
return "action_slot_reset" | ||
|
||
def run(self, dispatcher, tracker, domain): | ||
return [AllSlotsReset()] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
language: "en" | ||
pipeline: | ||
- name: SpacyNLP | ||
model: "en_core_web_md" | ||
- name: SpacyTokenizer | ||
- name: SpacyFeaturizer | ||
- name: RegexFeaturizer | ||
- name: LexicalSyntacticFeaturizer | ||
- name: CountVectorsFeaturizer | ||
- name: CountVectorsFeaturizer | ||
analyzer: "char_wb" | ||
min_ngram: 1 | ||
max_ngram: 4 | ||
- name: DIETClassifier | ||
epochs: 50 | ||
- name: EntitySynonymMapper | ||
- name: ResponseSelector | ||
epochs: 50 | ||
policies: | ||
- name: MemoizationPolicy | ||
- name: TEDPolicy | ||
max_history: 5 | ||
epochs: 100 | ||
- name: RulePolicy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# 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_channel: "C02D2NBG2RX" # channel ID, not a channel name! | ||
slack_token: "xoxb-XXX" # token obtained in the next step | ||
slack_signing_secret: "YYY" # secret obtained in the next step | ||
|
||
#socketio: | ||
# user_message_evt: <event name for user message> | ||
# bot_message_evt: <event name for but messages> | ||
# session_persistence: <true/false> | ||
|
||
rasa: | ||
url: "http://localhost:5005/webhook" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
## intent:affirm | ||
- yes | ||
- yep | ||
- yeah | ||
- indeed | ||
- that's right | ||
- ok | ||
- great | ||
- right, thank you | ||
- correct | ||
- great choice | ||
- sounds really good | ||
- thanks | ||
|
||
## intent:goodbye | ||
- bye | ||
- goodbye | ||
- good bye | ||
- stop | ||
- end | ||
- farewell | ||
- Bye bye | ||
- have a good one | ||
- Goodbye | ||
- Nothing thank you | ||
|
||
## intent:greet | ||
- hey | ||
- howdy | ||
- hey there | ||
- hello | ||
- hi | ||
- good morning | ||
- good evening | ||
- dear sir | ||
|
||
## intent:restaurant_search | ||
- i'm looking for a place to eat | ||
- I want to grab lunch | ||
- I am searching for a dinner spot | ||
- I am looking for some restaurants in [Delhi](location). | ||
- I am looking for some restaurants in [Bangalore](location) | ||
- show me [chinese](cuisine) restaurants | ||
- show me [chines]{"entity": "cuisine", "value": "chinese"} restaurants in the [New Delhi]{"entity": "location", "value": "Delhi"} | ||
- show me a [mexican](cuisine) place in the [centre](location) | ||
- i am looking for an [indian](cuisine) spot called olaolaolaolaolaola | ||
- search for restaurants | ||
- anywhere in the [west](location) | ||
- I am looking for [asian fusion](cuisine) food | ||
- I am looking a restaurant in [294328](location) | ||
- in [Gurgaon](location) | ||
- [South Indian](cuisine) | ||
- [North Indian](cuisine) | ||
- [Italian](cuisine) | ||
- [Chinese]{"entity": "cuisine", "value": "chinese"} | ||
- [chinese](cuisine) | ||
- [Lithuania](location) | ||
- Oh, sorry, in [Italy](location) | ||
- in [delhi](location) | ||
- I am looking for some restaurants in [Mumbai](location) | ||
- I am looking for [mexican indian fusion](cuisine) | ||
- can you book a table in [rome](location) in a [moderate]{"entity": "price", "value": "mid"} price range with [british](cuisine) food for [four]{"entity": "people", "value": "4"} people | ||
- [central](location) [indian](cuisine) restaurant | ||
- please help me to find restaurants in [pune](location) | ||
- Please find me a restaurantin [bangalore](location) | ||
- [mumbai](location) | ||
- show me restaurants | ||
- please find me [chinese](cuisine) restaurant in [delhi](location) | ||
- can you find me a [chinese](cuisine) restaurant | ||
- [delhi](location) | ||
- please find me a restaurant in [ahmedabad](location) | ||
- please show me a few [italian](cuisine) restaurants in [bangalore](location) | ||
- [Lesser than Rs. 300](price_range) | ||
- [Rs. 300 to 700](price_range) | ||
- [More than 700](price_range) | ||
- [Mexican](cuisine) restaurant in [Mumbai](location) | ||
- [LessThan300](price_range) | ||
- [Mexican](cuisine) Restro in [China](cuisine)[]{"entity": "location", "value": "China"} | ||
- Find a restaurant in [Mumbai](location) then | ||
- Find me a [chinese](cuisine) restaurant in [Delhi](location) | ||
- [MoreThan700](price_range) | ||
- [Mexican](cuisine) restro in [Delhi](location) | ||
- [Mexican](cuisine) in [Bhutan](location) | ||
- Chnage the city to [Delhi](location) | ||
|
||
## intent:send_email | ||
- Yes, My email address is [namratabafna14@gmail.com](cust_email) | ||
- Yup, My email-id is [deepakgupta0021@gmail.com](cust_email) | ||
- My mail address is [mlengineernamrata@gmail.com](cust_email) | ||
- abc@gmail.com | ||
- abc123@gmail.com | ||
- My email id is [namratabafna14@gmail.com](cust_email) | ||
- Yes it's [namratabafna14@gmail.com](cust_email) | ||
- Three00To700 | ||
- Yes please send it on [deepakgupta0021@gmail.com](cust_email) | ||
- Please send it to [deepakgupta0021@gmail.com](cust_email) | ||
|
||
## synonym:4 | ||
- four | ||
|
||
## synonym:Delhi | ||
- New Delhi | ||
|
||
## synonym:bangalore | ||
- Bengaluru | ||
|
||
## synonym:chinese | ||
- chines | ||
- Chinese | ||
- Chines | ||
|
||
## synonym:mid | ||
- moderate | ||
|
||
## synonym:vegetarian | ||
- veggie | ||
- vegg | ||
|
||
## regex:cust_email | ||
- ^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$ | ||
|
||
## regex:greet | ||
- hey[^\s]* | ||
|
||
## regex:pincode | ||
- [0-9]{6} |
Oops, something went wrong.