Issue with displaying messages using dispatcher in Rasa bot connected to Azure Bot on Teams

Hello!

I developed a bot using Rasa, and it’s currently connected to an Azure Bot via a webhook, and I have it activated on the Teams channel. In general, it’s functioning normally and provides responses within the Teams bot conversation. However, there are occasions when I’m using dispatcher.utter_message(text="example text") in the actions.py file to display messages within the bot conversation, but although no error is generated, the response message isn’t displayed within the conversation. Typically, the dispatcher works fine, even with AdaptiveCards that I’m using for Teams, but sometimes the messages fail to appear. I’ve been thinking that there might be a time limit, and after this time, it’s not possible to display the message with the dispatcher within the bot in Teams.

I would appreciate it if someone has knowledge about this and can clarify this issue for me.

Thank you!

The debug log should help you troubleshoot this. There is a 20 sec time limit if you think the action maybe running a long time.

1 Like

I’ve been conducting some tests and using the --debug option with the rasa run command. It’s worth noting that it’s a Rasa form I’m dealing with. I’ve noticed that responses don’t appear in the Teams bot when the process takes longer than 25 seconds, as you mentioned, indicating there’s a time limit in place. Additionally, it seems to be not just a dispatcher issue, because when it exceeds the 25-second limit, the form doesn’t complete. I attempted to display the same response from an action defined in rules.yml after completing the form slot, but it doesn’t transition to that next action; it remains stuck in the same form waiting for the single slot required to be completed.

Is there any way to extend this time limit? The process I’m undertaking takes longer than that, and it’s not possible for me to complete the form to continue with the rest of the flow.

I would appreciate any guidance you can provide.

I would focus on figuring out where the 25 seconds is going by looking at the Rasa log and action server log.

Thank you for the response. We’ve been closely monitoring the logs. The issue we’re encountering is that the bot is undergoing some AI text generation processes. Since these processes tend to take a significant amount of time, it’s crucial to have more time to complete them and subsequently display the results through the dispatcher. Is there a way we can address this aspect? We’ve attempted to reduce the time in various ways; however, these processes often take longer than 25 seconds.

You could implement a separate process that handles the LLM interactions and use Rasa external events to send back replies but this adds complexity.

I’d work on reducing the LLM response time. Are you using GPT4 and is the result generating a lot of output tokens?

Yes, currently we’re utilizing GPT-4 to generate text for crafting one-page documents from a specific prompt. Due to this, the output contains a significant number of tokens, which often leads to a considerable time delay in the process.

Could you please clarify if it’s feasible to implement a separate process as you mentioned?

You would create a separate process (in any language you want), the action server would call your process (with REST if you want) to handle the LLM call and pass any info needed by the LLM along with the Rasa sender id. The REST call to your process would respond immediately so that the custom action would would continue and tell the user “we’re processing your request” or something like that.

The process then does the interaction with the LLM. On completion, it uses the sender_id that was passed in the REST call and send the response to Rasa as described in the docs here. Note in the curl example shown here, the sender_id is user123.

Hello, I have been following the steps you provided and the documentation for external events. First, I have a form “validate_doc_generation_questions_form” where I receive four answers from the user and save them in different slots (respuesta1, respuesta2, respuesta3, respuesta4). The form doesn’t end until all four slots are completed. After completing the form, I have set an action “action_confirm_document” that retrieves the values of these slots and sends them via POST to a Python API which receives these four variables, processes them accordingly, and triggers an intent called “set_document_text,” returning the result in a single variable “short_url” to the Rasa server as follows:

rasa_endpoint = f"http://localhost:5005/conversations/{sender_id}/trigger_intent?output_channel=latest"
headers = {'Content-Type': 'application/json'}
response = {
    "name": "set_document_text",
    "entities": {
        "document_url": short_url
    }
}
try:
    response = requests.post(rasa_endpoint, json=response, headers=headers)
except requests.RequestException as e:
    print(f"Error: {e}")
    return {"status": "fail"}

I have defined the entity and the slot in the domain.yml as follows:

entities:
- document_url

document_url:
    type: text
    influence_conversation: false
    mappings:
    - type: from_entity
      entity: document_url

Additionally, I have defined a rule for that specific intent in the following way:

- rule: Set Document Text
  steps:
  - intent: set_document_text
  - action: action_document_text

In the custom action “action_document_text,” which is triggered by the intent, the value of the entity or slot “document_url” is printed using the tracker and dispatcher as follows:

class ActionDocumentText(Action):

    def name(self) -> Text:
        return "action_document_text" 

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        doc_url = tracker.get_slot("document_url")
        dispatcher.utter_message(text=f"You can access the generated document at the following link: {doc_url}")

The process of sending information to the API and the processes within the API are executed correctly. However, when I try to send back the intent and the value of the entity to the Rasa server, it gets stuck at this point and doesn’t move to the next action where the API result is expected to be printed. It remains stuck at the line after the try where the request is made: response = requests.post(rasa_endpoint, json=response, headers=headers)

These are the logs on the Rasa server:

It seems as though it’s as if the form is being reactivated and the last slot “respuesta4” is being filled again, even though it had already been completed entirely and had moved on to the next action.

Sounds like you’re almost there. To directly invoke the intent you should use the slash syntax: /set_document_text

Hello, from the API where I’m processing, I’m currently sending the information like this with the slash:

However, in the Rasa logs, I’m encountering the following:

It seems like it’s not identifying the intent correctly. I have this intent defined in both domain.yml and rules.yml for the action I want to proceed with, like so:

domain.yml

image

rules.yml

image

Additionally, I’ve defined the entity and slot for ‘document_url’ as follows:

image

image

It seems that it’s not correctly identifying the triggered intent nor the value for the ‘document_url’ entity.

In the example I gave I assumed you were using the REST channel.

How can I use that channel? I’m connecting to a Teams channel through BotFramework and I need the bot’s responses there.

At the moment, I have added this to the credentials.yml file:

What could I do in this case or what would I need to add?