使用Slack时Microsoft Bot Framework IDialogContext.Call()不起作用

问题描述:

我使用IDialogContext.Call()在我的机器人中进行了一个简单的子对话框调用.当用户键入新项目"时,将调用以下代码:

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()只是询问一个项目名称,然后将其保存,然后返回到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);
    }
}

从模拟器,Skype或Webchat调用该漫游器后,一切正常.用户通过键入新项目"来请求新项目,机器人会询问名称,它会等待,一旦用户输入了项目名称,机器人便会确认新项目的创建.

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.

但是当我从Slack调用相同的名称时,当用户通过键入新项目"来请求新项目时,文本新项目"将传递到NewProjectDialog.它要求提供项目名称,但没有等待它就进一步传递新项目"并将其保存为项目名称.

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.

不太确定我想念的是什么. iDialogContext.Wait()与Slack的工作方式有所不同,或者Call()函数似乎将消息发布到子对话框,就像Forward()应该那样.

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.

感谢某些 Howdy开发人员我找到了问题.

Thanks to some Howdy developers I found the issue.

当机器人已被授权给团队,然后其他人进入并再次授权该机器人时,就会发生这种情况.发生这种情况时,似乎有两个机器人在运行,然后使用相同的RTM连接两次发布到该频道.

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.

我不知道如何在同一个Slack客户端中获得2个机器人.但是一旦我删除并重新安装了我的漫游器,它便开始按预期运行.

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.

同一问题导致了另一种症状: Microsoft Bot Framework Bot重复Slack中的响应

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