Hello,
How can i send a message to the user when an error occurred ?
I handle any bot errors with bot.on('error')like that :
javascript
// log any bot errors into the console
bot.on('error', function (e) {
console.log('And error ocurred', e);
});
But i can't make a session|bot.send without session or adresse object.
Any help ?
I hope what I have requested is possible.
Thank you
Can't you just use a Try Catch? When you catch an exception, send a message?
I have a lot of dialogs with waterfall steps, i need to use try catch (or session.on("error")) in every step !!
With bot.on("error") i catch all unhandled errors in any dialog, but i cant access to the user address or a session instance.
@ouadie-lahdioui It's hard to say the best solution without seeing your bot code.
Can you post your code that is causing the problem?
closing as no response
Please reopen. The problem is obvious that session.send is asynchronous but does not provide a callback function.. try/catch does not work and session|bot.on-error does not help as long as on-error does not contain any info about which message failed.
I got the same problem (rarely and randomly.. can't reproduce it, but occurs every few minutes )and see in the logs:
bot.error: {"code":"EAI_AGAIN","errno":"EAI_AGAIN","syscall":"getaddrinfo","hostname":"state.botframework.com","host":"state.botframework.com","port":443}
it seems I got a problem with the proxy because without proxy it works.. workaround would be to send the failed message again.. but until now I don't know which message fails ;(
Sorry for the late response, i have found a solution to my problem. Thanks
@jazzmn what do you mean by "...on-error does not contain any info about which message failed..." ? what are you looking for exactly ?
@ouadie-lahdioui if I use
bot.on('error', function(e) {}
then I dont't know which message exactly failed or even which user is affected.
You're right 👍
Guys, any way to get more data when catching errors with bot.on('error', ...)event listener ?
here's an example of code where i cannot send a message to the user to notify them that there're an error.
````
const defaultDialogName: string = "/Main";
let bot: Builder.UniversalBot;
bot = new Builder.UniversalBot(connector, (session) => {
session.beginDialog(defaultDialogName);
});
bot.dialog(defaultDialogName, [
function (session, args) {
// do some cool stuff ...
// to simulate an error, i'll start an unexist dialog
session.beginDialog("/UNREAL", {message});
}
]);
bot.on('error', function (e) {
console.log(e);
// i want to send a message to the user !
// can i use session|bot.send here ?
});
````
You prefer reopen the issue and continue the discussion here or should i crate a new one ?
Thank you for your help
i would reopen it.. i think it's still the same problem which is unsolved until now.
UP, did any of you guys found a way to send message or start a dialog for uncaught errors ?
Thank you for your submission. The Microsoft Bot Framework team prefers that bug fixes and feature requests were opened as new issues on the official Bot Framework Github repo. The Stack Overflow botframework tag is a place to ask how to questions and get support from the community. Please feel free to submit an issue on GitHub, and the dev team will look into your request.
An update on this feature request anyone? I too have the need of catching all unhandled errors in any dialog, but can't access the user address or a session instance
This issue isn't being worked on as a feature request, if you would like to create an issue along those lines please open a new issue describing the use case.
Hi @ouadie-lahdioui what solution worked for you. We want to retry message in case when we get Http response 429 too many requests while sending message.
Most helpful comment
Please reopen. The problem is obvious that session.send is asynchronous but does not provide a callback function.. try/catch does not work and session|bot.on-error does not help as long as on-error does not contain any info about which message failed.
I got the same problem (rarely and randomly.. can't reproduce it, but occurs every few minutes )and see in the logs:
bot.error: {"code":"EAI_AGAIN","errno":"EAI_AGAIN","syscall":"getaddrinfo","hostname":"state.botframework.com","host":"state.botframework.com","port":443}
it seems I got a problem with the proxy because without proxy it works.. workaround would be to send the failed message again.. but until now I don't know which message fails ;(