Need to catch HTTP request error in Composer

Viewed 413

I have a bot in Composer 1.3 and I use "Send an HTTP request" throughout. That's all working fine.

However, if the bot cannot reach the endpoint, it sends a message back to the user saying "No connection could be made because the target machine actively refused it." and the dialog ends. In the snippet below, the second trace event is not reached when the web service is not available.

To the end users, that is pretty unintelligible.

Is there a way to catch this error so I can respond to the user in a more user friendly fashion? I'd rather say that the system is down or inaccessible right now.

snippet from composer, error emanates from HTTP request

2 Answers

You can use 'error occured' dialog trigger to capture any runtime error. And inside that trigger you can send your custom response.

If you need to return more info to the user about the error, use the Dialog Error Event trigger.

Create trigger modal with Dialog Events & Error occurred selected

You can get the details of the error from turn.dialogEvent inside the trigger, ex:

Error: ${turn.dialogEvent.value.name}
Details: ${turn.dialogEvent.value.message}

This is tested and working in Bot Framework Composer v2.1

Related