When there is a problem with action server, Rasa raises “Failed to execute custom action.” and responds (to REST channel) with an empty list and status 200.
Is there anyway to have a default utterance for this occasion?
As an example can we define that in case action server fails, respond with “Sorry, our servers seems to have some problem. Please try again in sometime.”
Or at least include something in the response (or the change the status) so front-end can find out, the problem is with action server.
You can have an exception for when the status is not 200, or even if there is an HTTP error. I quote below some lines that I’ve used in the past for an external API. I’m only guessing that you could use the internal endpoint as well.
try:
response = requests.request("POST", request_url, headers=headers, data=payload, verify=False)
att = json.loads(str(response.text))
status = att.get('statusCode',False)
if status == '200':
# do something
else:
# return something if for example you receice status 500
except requests.exceptions.HTTPError as err:
raise SystemExit(err)
dispatcher.utter_message(text="Apparently the server is down..")
Since Rasa core sends request to action server within itself, I am not sure where this code would go?
Just to be clear I meant when Rasa core cannot get answer from Rasa SDK at all, not when Rasa SDK faces a problem with a request to an external server. (Let’s say as an example when Rasa SDK server is down all together.)
Fair point @f.batiri. I used this code in the custom action when I wanted to call an external API. I learned the exception the hard way since the endpoint was constantly failing…
From security perspective, I think it’s quite odd to monitor Rasa from within Rasa. Where are you hosting Rasa compoments? For example, if you’re using containerized Rasa (e.g.: via Docker), perhaps you could use an external service such as https://prometheus.io/.