我想使用dispatcher.utter_message来显示消息,即使插槽不存在或找不到时也该怎么办。我在下面为自定义操作编写了代码,其中有时找不到插槽,但我想分派消息。我怎样才能做到这一点。请帮助
from future import absolute_import from future import division from future import unicode_literals
from rasa_core_sdk import Action from rasa_core_sdk.events import SlotSet import pandas as pd
df = pd.read_excel(“C:\Samples\faqxxx.xlsx”)
class ActionWeather(Action):
def name(self):
return 'action_weather'
def run(self,dispatcher, tracker, domain):
loc = tracker.get_slot('faq')
msg=tracker.latest_message['text']
print(msg)
intent_name = tracker.latest_message['intent'].get('name')
result = df['fixit'][df['faq'] == intent_name]
dispatcher.utter_message(result[0])
return [SlotSet('faq', loc)]