Async Timeout On Slack
I'm having some trouble trying to implement a picture description bot for slack, from what I can tell it's an issue with slack timing out if a response isn't received from an async method after a certain amount of time.
I've tested the code below without the DescribeAsync method and it sends a response to slack just fine, however with it, I get absolutely nothing.
[Serializable]
public class VisionController : IDialog
{
public async Task StartAsync(IDialogContext context)
{
context.Wait(MessageReceivedAsync);
}
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable<Message> argument)
{
var message = await argument;
var client = new VisionServiceClient("my key goes here");
var result = await client.DescribeAsync(message.Text);
await context.PostAsync(result.Description.Captions[0].Text);
context.Wait(MessageReceivedAsync);
}
}
This class is called from
return await Conversation.SendAsync(message, () => new VisionController());
I believe that the switch will timeout after 100 seconds, and I don't know what Slacks time out is. If you are going to take longer than 15 seconds I recommend you return an empty response immediately and then send a response async when you actually have the completed data.
Could you elaborate a bit further on how to do this? I assumed the slack integration was abstracted away, with us being unable to send such responses. @tomlm
To add to my previous comment, it's possible that it's not slack timing out at all, however it seems the most likely cause given that I'm not receiving any response at all, but the code works perfectly in the emulator.
Try something like this:
Task.Run( async () =>
{
var client = new VisionServiceClient("my key goes here");
var result = await client.DescribeAsync(message.Text);
// create connector client and send response
var connectorClient = new ConnectorClient(new Uri((message.From.ChannelId == "emulator") ? "http://localhost:9000" : "https://api.botframework.com"), new ConnectorClientCredentials());
await connectorClient.Messages.SendMessageAsync(message.CreateReplyMessage(result.Description.Captions[0].Text));
});
await context.PostAsync("I'm working on it");
context.Wait(MessageReceivedAsync);