Problem: I wanted to fetch the entity from the user’s question and match it with the list of entities stored in a google sheets but it is fetching only the entities which are present in the training data, if the entity is not from the training data it gives ‘None’ as the slot value. How to deal with this ?
please help me resolve this issue.
If you have an intent related to the slot filling, you can make a custom action to search words from the user message in the google sheet and set the slot with an event.
If you don’t, you can use a form, ask directly for the value of the slot (with mapping from_text(intent=None)), search the value in the google sheet and assign it.
Another option, if your list is relatively small, is to add the entire list to a lookup table.
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint
import pandas as pd
scope = ["https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("cred.json", scope)
client = gspread.authorize(creds)
sheet = client.open("rasa") # Open the spreadsheet
worksheet = sheet.get_worksheet(0)
x = worksheet.get_all_records()
pprint(x)
data = pd.DataFrame(x) # Get a list of all records
skil = tracker.get_slot("skill")
print(skil)
a = []
for i,v in enumerate(data['skill']):
#print(v, skil)
if v == skil:
a.append('y')
else:
a.append('n')
#print('this is a', a)
if 'y' in a:
dispatcher.utter_message("Yes")
else:
dispatcher.utter_message("Noooo")
return (a)
yes thanks @Bala but it is giving the entity name for the training data and when it comes to the data outside from the training data it is giving the slot value as ‘None’ even the data is valid question and i’ve checked the confidence it’s showing around 97 why is this heppening?