Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bot Framework Sending Unnecessary Error Messages

I create a bot, called picturesaver, using Microsoft's Bot Framework, I added a GroupMe channel, and I have it hosted in Azure. The bot works perfectly, saving pictures to Google Drive.

However, the bot gives an error saying "Service Error:POST to picturesaver timed out after 15s" Is it possible to extend the timeout time? Or even stop the bot from posting anything at all. Could this be an Azure issue or is it a GroupMe issue?

like image 855
Kyle Avatar asked Feb 20 '26 09:02

Kyle


2 Answers

If your bot performs an operation that takes longer than 15 seconds to process a message, you can process the message on another thread, and acknowledge the call right away. Something like:

public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
    if (activity.Type == ActivityTypes.Message)
    {
        if ([determine if this will take > 15s]) 
        {
            // process the message asyncronously
            Task.Factory.StartNew(async () => await Conversation.SendAsync(activity, () => new Dialogs.RootDialog()));
        }
        else
        {
            //process the message normally
            await Conversation.SendAsync(activity, () => new Dialogs.RootDialog());
        }
    }

    return Request.CreateResponse(HttpStatusCode.OK); //ack the call
}

This will avoid the 15 second timeout between connector and bot.


Edit: the above will not scale, and is just using a Task.Factory. Please refer to https://learn.microsoft.com/en-us/azure/bot-service/bot-builder-howto-long-operations-guidance for the recommended guidance on processing long operations from a bot.

like image 66
Eric Dahlvang Avatar answered Feb 21 '26 21:02

Eric Dahlvang


The Bot Connector service has a 15s timeout so you need to make sure any async API calls are handled in that timeframe, or make sure your bot responds with some kind of message if it's waiting for some other operation to complete. Currently the 15s timeout cannot be modified.

like image 25
nwxdev Avatar answered Feb 21 '26 23:02

nwxdev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!