Handling API exception in action server with a user-friendly bot utterance

Hi, I call an external API from within the Rasa actions server (Rasa open source 2.8.8). Specifically, I use a try-catch block and use a dispatch.utter_message in the except block to have the bot display a user-friendly message when there is an exception like a connection issue. But, the bot prints nothing from within the action server whenever an exception is encountered. Any pointers would be of great help.


What’s your front-end? Rasa Shell, Rasa X, or something else? Rasa X sometimes fails to display the message on actions that make database queries and API calls.

You can use print() inside the action and it will get printed in the action server’s logs.

Hi - thanks for your response.
My front-end is Rasa Webchat JavaScript.
For the successful API requests, I am able to print the responses. It is when the API server is down when I am unable to send a meaningful response to the user.

Did you put a print() in the except block to make sure it’s getting there?

Thanks for your suggestion. It indeed wasn’t getting to the except block. There was some issue with my code changes not reflecting in the action server. Clearing the pycache folder helped and now, it works as expected. Thanks again


Thanks for the solution , i was facing same problem except block was not working in actions.py file , after clearing pycache folder now it is working fine. thanks a lot for the solution