Reputation: 23
I’am using http api and i want to return from action json response instead of text. I took a look documentation then found dispatcher utter_response. I tried to use it but i got errow below.
Error:
'CollectingDispatcher' object has no attribute 'utter_response'
my action class:
class ActionRoute(Action):
def name(self):
return 'action_route'
def run(self, dispatcher, tracker, domain):
location = tracker.get_slot('location')
travelmode = tracker.get_slot('travelmode')
data = {
"travelmode":travelmode,
"location":location
}
response = "Hedef: {} ulaşım tercihi:{}".format(location,travelmode)
dispatcher.utter_response(json.dumps(data))
return [SlotSet("location", location),SlotSet("travelmode", travelmode)]
domain.md
actions:
- utter_greet
- action_route
- utter_goodbye
entities:
- location
- travelmode
intents:
- goodbye
- greet
- address
slots:
location:
type: text
travelmode:
type: text
templates:
utter_goodbye:
- text: Güle güle
- text: Kendine iyi davran
- text: Allaha emanet ol
utter_greet:
- text: Merhaba! Bugün nereye gitmek istersin?
- text: Merhaba! Seni nereye götürüyüm?
utter_default:
- text: Seni tam anlamadım gideceğin yeri tekrar söyleyebilirmisin
- text: Nasıl tam anlamadım. Bir daha söyler misin?
Upvotes: 0
Views: 1166
Reputation: 111
As per the official documentation of rasa_core, there is a method defined with name utter_response. In your case i guess you are importing Action from rasa_sdk
.
if you are using:
from rasa_core.actions.action import Action
then use: dispatcher.utter_response(...)
if you are using:
from rasa_core_sdk import Action
then use: dispatcher.utter_attachment(...)
Upvotes: 1