How to set response in Rasa

I have created a pipeline in rasa which looks like this.


language: en

pipeline:

  - name: components.data_processing.DataProcessingComponent # preprocess

  - name: components.data_processing.FastAPIComponent

The last FastAPIComponent processes the request message and produces the response. I want to set that response in rasa so that rasa can send that response to the user.


This is the sample response of FastAPIComponent. It can generate both text and button responses.

{ ‘intent’: {‘name’: ‘greet’, ‘confidence’: 0.9999999403953552}, ‘entities’: None, ‘response’: [{‘recipientId’: None, ‘text’: “Hey! How are you today?”, ‘buttons’: None}]}


Thanks in Advance.

Why not the FastAPI as a custom action?

Hi @stephens, you mean to say to call custom action directly from the FastAPI component?

Write a rule or story:

- rule: greet
  steps:
  - intent: greet
  - action: action_fastapi_response

action_fastapi_response is a custom action that calls dispatcher.utter_message with your generated response.

@stephens we have to handle multiple rasa models at once and we do that by using rasa agent in our fastapi application. The fastAPI component interacts with our fastapi application and send us back the final response. So even intent detection takes place there. The above config that you see does

  1. Preprocess the text
  2. Sends the text to the fastapi server and gets response in return

Now we need to set this response in our rasa , if it was text only we could easily set that, it’s the buttons that we are trying to find out way for.

ok, but the NLU pipeline is not the place to handle responses.

I don’t fully understand your architecture (wonder why you don’t follow a standard approach with each model hosted by a Rasa instance) but I don’t think your approach fits in well with the Rasa architecture.

NLU and Dialog have always been separate in Rasa. Since you’re doing both in the same component, I’m not sure that Rasa fits well.