Hello RASA Community,
I have two similar questions and appreciate your comments/suggestions.
- How to return a json from custom action. currently I am doing using below converting json to string and using utter_message to return the response but I believe that’s not the best efficient way
class ActionSearchTrackingID(Action): def name(self): # define the name of the action which can then be included in training stories return “action_search_trackingID”
def run(self, dispatcher, tracker, domain):
# what your action should do
query = 'field:' + tracker.get_slot('ID')
request = requests.get('http://localhost:8983/solr/coll/select?indent=on&q=' + query + '&wt=json').text #make an apie call
dispatcher.utter_message(request) #send the message back to the user
return []
- If you Action server is outside python, I am able to call and there also how to return the json response. Currently I am using below text field to put String json but again that may not be the best way
{ “events”: [], “responses”: [ {“text”: “json as string”} ] }