Есть ли способ, которым я могу связать диалог с Луисом - PullRequest
0 голосов
/ 01 февраля 2019

Я пытаюсь вызвать диалог из моего намерения Луиса.Но я получаю ошибку.пожалуйста, проверьте мой код. Он достигает диалогового окна UserInteraction, но элемент управления не переходит к Getuserpurpose.It показывает ошибку «у моего бота-кода проблема»

Я попытался отладить и обнаружил, что элемент управления переходит кКонфигурационный класс Webapi после запуска StartAsync.

[LuisIntent("Getfile")]
    public async Task GetfileIntent(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("Sure we can help you on that... ");
        //PromptDialog.Text(context, UserEnteredInfo, "can you please provide us with below info. " +
        //    "Purpose" + "Client name" + "Team Name");
        await context.PostAsync("But first i need to know the purpose ");
      //  Conversation.SendAsync(Activity, () => new UserInteraction());
       context.Call(new UserInteraction(),ResumeAfterFeedback);

    }
    private async Task ResumeAfterFeedback(IDialogContext context, IAwaitable<object> result)
    {
        await context.PostAsync("Prepared an email for you");
        context.Wait(MessageReceived);
    }


[Serializable]
public class UserInteraction : IDialog<object>
{
    protected string Purpose { get; set; }
    protected string ClientName { get; set; }
    protected string Teamname { get; set; }

    public async Task StartAsync(IDialogContext context)
    {
        await context.PostAsync("Please enter the purpose");

       // context.Wait(this.MessageReceivedAsync);
        context.Wait(Getuserpurpose);

    }
    public async Task Getuserpurpose(IDialogContext context, IAwaitable<IMessageActivity> argument)
    {
        var message = await argument;
        this.Purpose = message.Text;
        await context.PostAsync("Now please tell me the client name");
        context.Wait(Getuserclient);

    }

1 Ответ

0 голосов
/ 05 февраля 2019

Я только что проверил это, и оно работает как ожидалось.

[LuisIntent("Getfile")]
    public async Task GetfileIntent(IDialogContext context, LuisResult result)
    {
        await context.PostAsync("Sure we can help you on that... ");
        await context.PostAsync("But first i need to know the purpose ");
       context.Call(new UserInteraction(),ResumeAfterFeedback);

    }
    private async Task ResumeAfterFeedback(IDialogContext context, IAwaitable<object> result)
    {
        var interactionResult = await result as UserInteraction;
        await context.PostAsync("Prepared an email for you");
        context.Wait(MessageReceived);
    }


    [Serializable]
    public class UserInteraction : IDialog<object>
    {
        protected string Purpose { get; set; }
        protected string ClientName { get; set; }
        protected string Teamname { get; set; }

        public async Task StartAsync(IDialogContext context)
        {
            await context.PostAsync("Please enter the purpose");
            context.Wait(Getuserpurpose);

        }
        public async Task Getuserpurpose(IDialogContext context, IAwaitable<IMessageActivity> argument)
        {
            var message = await argument;
            this.Purpose = message.Text;
            await context.PostAsync("Now please tell me the client name");
            context.Wait(Getuserclient);

        }

        private async Task Getuserclient(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            var message = await result;
            ClientName = message.Text;
            await context.PostAsync("Now please tell me Team Name");
            context.Wait(GetUserTeamName);
        }

        private async Task GetUserTeamName(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            var message = await result;
            Teamname = message.Text;
            await context.PostAsync("Got it");
            context.Done(this);
        }
    }
...