Dialog的StartAsync方法继承BestMatchDialog Not Invoking

时间:2018-03-08 15:41:01

标签: botframework

我在我的机器人中创建了BestMatchDialog,我想在其StartAsync方法中执行一些任务。但问题是startasync方法没有遇到实现BestMatchDialog的对话框。 我的代码如下

[Serializable]
public class GreetingsDialog : BestMatchDialog<object>
{
    [AsyncStateMachine(typeof(BestMatchDialog<object>))]
    public async Task StartAsync(IDialogContext context)
    {
        try
        {
            //Some code to execute
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    [BestMatch(
        new string[] {
                    "test", "test1", "test2", 
                })]
    public async Task Test(IDialogContext context, string messageText)
    {
            string[] Answers =
                { "Hello there. Test",
                  "just going to say hi",
                  "hello my friend",
                  "heyya !!"
                };

            int index = new Random().Next(0, (Answers.Length - 1));
            await context.PostAsync(Answers[index]);
            context.Done(true);
        }
    }


}

1 个答案:

答案 0 :(得分:0)

我认为这与继承有关,请尝试使用此

public override async Task StartAsync(IDialogContext context)

而不是

public async Task StartAsync(IDialogContext context)