Return json response using dispatcher

Hi, I am a new in rasa. I’am using http api and i want to return json response instead of text. I took a look documentation then found dispatcher.response. I tried to use it but i got errow below.

'CollectingDispatcher' object has no attribute 'utter_response'

My action code:

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 = {
        response = "Hedef: {} ulaşım tercihi: {}".format(location,travelmode)

        return [SlotSet("location", location),SlotSet("travelmode", travelmode)]

Is there anyone that have experienced before? Please help me?

I don’t know where you found utter_response, but I only find :

  • utter_message
  • utter_custom_message
  • utter_attachment
  • utter_button_message
  • utter_button_template
  • utter_template

RASA docs do have dispatcher.utter_response() but for sending messages to client. Take a look at this: dispatcher.

But the dispatcher in custom action is a CollectingDispatcher, which do not have this method I think

I just checked, you were right, Collectingdispatcher does not have this method.

I have seen in here. rasa_core.dispatcher

I have had a similar need, and resolved it by not using the dispatcher.utter_response() method, but storing arbitrary JSON structures-encoded-as-strings in unfeaturized Rasa slots.

@JohnDowding how exactly did you do that? Can you post your code here I am facing the same problem Did you use dispatcher.utter_message?