botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Node.js SDK, Question] Send a message to user when an error occurred

Open ouadie-lahdioui opened this issue 9 years ago • 14 comments

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 :

// 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

  • SDK Platform: Node.js

ouadie-lahdioui avatar Oct 12 '17 13:10 ouadie-lahdioui

Can't you just use a Try Catch? When you catch an exception, send a message?

NathanCOakes avatar Oct 12 '17 15:10 NathanCOakes

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 avatar Oct 12 '17 15:10 ouadie-lahdioui

@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?

nwhitmont avatar Oct 12 '17 18:10 nwhitmont

closing as no response

nwhitmont avatar Oct 25 '17 18:10 nwhitmont

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 ;(

jazzmn avatar Nov 13 '17 11:11 jazzmn

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 avatar Dec 04 '17 16:12 ouadie-lahdioui

@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.

jazzmn avatar Dec 06 '17 16:12 jazzmn

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

ouadie-lahdioui avatar Dec 06 '17 21:12 ouadie-lahdioui

i would reopen it.. i think it's still the same problem which is unsolved until now.

jazzmn avatar Dec 07 '17 13:12 jazzmn

UP, did any of you guys found a way to send message or start a dialog for uncaught errors ?

Samox avatar Mar 20 '18 13:03 Samox

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.

JasonSowers avatar Jun 28 '18 15:06 JasonSowers

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

wkk91193 avatar Sep 02 '18 15:09 wkk91193

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.

sbuffkin avatar Sep 10 '18 23:09 sbuffkin

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.

sandeepjagtap avatar Jan 24 '20 11:01 sandeepjagtap