As the title states, rasa is seemingly refusing to run the action instead falling to fallback. I’ve given it interactive training stories with the correct flow and it still doesn’t work. All I want to do is be able to call the action so I can have custom response bodies without having to wait for the form action to call submit. Essentially I want to call this action after every user input and have it return a custom response body.
Side note I’ve tried to find other ways of sending a custom response body back to the user but I need access to the tracker for slot info, which I can’t access in my custom rest api.
The action I want to call
class ResponseBody(Action):
def name(self) -> Text: return "response_body" def run(self, dispatcher: CollectingDispatcher, tracker: Tracker, domain: Dict[Text, Any]): dispatcher.utter_message(tracker) return []
Right now I am just trying to get this action to work so all I have it do is return the tracker
Story data
Generated Story 6856553841717322574
- find_a_doctor
- search_providers_form
- form{“name”: “search_providers_form”}
- slot{“requested_slot”: “specialty”}
- inform{“specialty”: “cardiology”}
- slot{“specialty”: “cardiology”}
- response_body
- action_listen
- search_providers_form
- slot{“requested_slot”: “zipCode”}
- form: inform{“zipCode”: “23233”}
- slot{“zipCode”: “23233”}
- form: search_providers_form
- slot{“zipCode”: “23233”}
- form{“name”: null}
- slot{“requested_slot”: null}
- action_restart The form action works fine but it ignores my action when I tell it to execute it
Domain actions
actions:
- utter_set_isLive
- utter_out_of_scope
- utter_noworries
- utter_greet
- customized_fallback
- utter_goodbye
- utter_handle_insult
- utter_nice_to_meet_you
- utter_default
- utter_telljoke
- utter_ask_continue
- response_body
- utter_ask_howdoing
- action_chitchat
Rest API
class RestInput(InputChannel): “”"A custom http input channel.
This implementation is the basis for a custom implementation of a chat frontend. You can customize this to send messages to Rasa Core and retrieve responses from the agent.""" @classmethod def name(cls): return "bot" @staticmethod def on_message_wrapper(on_new_message, text, queue, sender_id): collector = QueueOutputChannel(queue) message = UserMessage(text, collector, sender_id, input_channel=RestInput.name()) on_new_message(message) queue.put("DONE") def _extract_sender(self, req): return req.json.get("sender", None) # noinspection PyMethodMayBeStatic def _extract_message(self, req): return req.json.get("message", None) def stream_response(self, on_new_message, text, sender_id): from multiprocessing import Queue q = Queue() t = Thread(target=self.on_message_wrapper, args=(on_new_message, text, q, sender_id)) t.start() while True: response = q.get() if response == "DONE": break else: yield json.dumps(response) + "\n" def blueprint(self, on_new_message): custom_webhook = Blueprint( 'custom_webhook_{}'.format(type(self).__name__), inspect.getmodule(self).__name__, template_folder='templates', static_folder='static') @custom_webhook.route("/", methods=['GET']) def health(): return jsonify({"status": "ok"}) @custom_webhook.route("/ui", methods=['GET']) def botui(): return render_template('index.html') @custom_webhook.route("/ui/", methods=['GET']) def botui4(): return render_template('index.html') @custom_webhook.route("/parse", methods=['POST']) def receive(): sender_id = self._extract_sender(request) text = self._extract_message(request) should_use_stream = utils.bool_arg("stream", default=False) if should_use_stream: return Response( self.stream_response(on_new_message, text, sender_id), content_type='text/event-stream') else: collector = CollectingOutputChannel() on_new_message(UserMessage(text, collector, sender_id, input_channel=self.name())) return jsonify(collector.messages) return custom_webhook
What am I doing wrong here? What do I need to do to have rasa send back a custom response body every time to the user?