Microsoft Bot Framework IDialogContext.Call() not working when using Slack

对着背影说爱祢 提交于 2019-12-24 10:59:21

问题


I have a simple child dialog call in my bot using IDialogContext.Call(). When user types "new project" the following code is called:

...
context.Call(new NewProjectDialog(), NewProjectConfirmed);
...

NewProjectDialog() just asks for a project name and then saves it before returning to NewProjectConfirmed()

[Serializable]
public class NewProjectDialog : IDialog<Project>
{
    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync("What is the name of the project?");
        context.Wait(this.MessageReceivedAsync);
    }

    public virtual async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
    {
        var message = await result;
        Project p = new Project();        
        //Saving project here...

        await context.PostAsync($"OK. Your project '{message.Text}' was created.");
        context.Done(p);
    }
}

When the bot is called from emulator, Skype or Webchat everything works as expected. User asks for new project by typing "new project", bot asks for name, it WAITS and once project name entered by the user the bot confirms the new project creation.

But when I call the same from Slack, When the user ask for new project by typing "new project" the text "new project" is passed to the NewProjectDialog. it asks for the project name, but without waiting it passes "new project" further and saves it as the name for the project.

Not really sure what I am missing. Either iDialogContext.Wait() works differently with Slack or the Call() function seem to post the message to the child dialog like Forward() should.


回答1:


Thanks to some Howdy developers I found the issue.

It happens when the bot has already been authorized to the team, and then someone else comes in and authorizes the bot again. When that happens, it seems there are two bots running that then use the same RTM connection to post to the channel twice.

I don't know how I got 2 bots in same Slack client. but once I removed and reinstalled my bot it started working as expected.

Same issue is causing this other symptom: Microsoft Bot Framework Bot duplicate responses in Slack



来源:https://stackoverflow.com/questions/46147921/microsoft-bot-framework-idialogcontext-call-not-working-when-using-slack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!