Команда "Справка" FormFlow и команда "Справка" для обработчиков Scorables/GlobalMessage

Когда диалог находится внутри FormFlow и пользователь вводит "Справка", в настоящее время "Справка" по глобальным обработчикам сообщений Scorables берет на себя управление. Я хотел бы, чтобы команда FormFlows "Справка" находилась внутри формы, а команда "Помочь" Scorables - только в других разговорах. Есть ли способ добиться этого?

protected override async Task PostAsync(IActivity item, string state, 
CancellationToken token) 
{ 
     var message = item as IMessageActivity; 

     if (message != null) 
     { 
          var helpDialog = new HelpDialog(); 
          var interruption = helpDialog.Void<object, IMessageActivity>(); 
          this.task.Call(interruption, null); 
          await this.task.PollAsync(token); 
     } 
}


public class HelpDialog : IDialog<object>
{
    public async Task StartAsync(IDialogContext context)
    {

        var userHelpMessage = "You have reached Help Section.\n"
                               + StaticMessages.HelpMessage
                               + "\n Your previous conversation is active 
         and you can return to prior dialog by typing 'Back' or 'Return'.";

        await context.PostAsync(userHelpMessage);

        context.Wait(this.MessageReceived);
    }

    private async Task MessageReceived(IDialogContext context, 
    IAwaitable<IMessageActivity> result)
    {
        var message = await result;

        var incomingMessage = message.Text.ToLowerInvariant();

        if ((incomingMessage != null) && (incomingMessage.Trim().Length > 0))
        {
            context.Done<object>(null);
        }
        else if (incomingMessage.Equals("return", StringComparison.InvariantCultureIgnoreCase))
        {
            context.Done<object>(null);
        }
        else if (incomingMessage.Equals("back", StringComparison.InvariantCultureIgnoreCase))
        {
            context.Done<object>(null);
        }
        else
        {
            context.Fail(new Exception("Message was not a string or was an empty string."));
        }
    }
}

[Сериализуемый] открытый класс BuildARCollRaiseDisputeForm {

    //Custom Form Builder for custom yes options
    BuildCustomForm customForm = new BuildCustomForm();
    ARCollRaiseDisputeQuery disputeQuery = new ARCollRaiseDisputeQuery();

    public IForm<ARCollRaiseDisputeQuery> BuildARCollRaiseDisputeForms()
    {

        IForm<ARCollRaiseDisputeQuery> form;

        OnCompletionAsyncDelegate<ARCollRaiseDisputeQuery> processARCollRaiseDisputeSave = async (context, state) =>
        {
            var message = $"Saving your dispute reason against this Invoice. ";

            await context.PostAsync(message);
        };

        var builder = customForm.CreateCustomForm<ARCollRaiseDisputeQuery>()

            .Field(nameof(disputeQuery.BODISPUTEREASONOPTIONS),
                    validate: async(state, value) => await ValidatePymtDisputeReason(state, value)
                   )

            .Field(nameof(disputeQuery.DisputeItemReasons),
                    active: state =>  ActiveDisputeItemReason(state)
                    )

            .Field(nameof(disputeQuery.DisputeShipmentReasons),
                    active: ActiveDisputeShipmentReason
                    )

            .Field(nameof(disputeQuery.DisputeInvoicingReasons),
                    active: ActiveDisputeInvoicingReason
                    )

            .Field(new FieldReflector<ARCollRaiseDisputeQuery>(nameof(disputeQuery.OtherPymtDisputeReason))
                .SetActive(state => ActiveOtherPymtDisputeReason(state))
                .SetPrompt(new PromptAttribute("Do you have any custom message to my team for non-payment for this Invoice? If yes, then please type and send as single message."))
                .SetValidate(async (state, value) => await ValidateOtherPymtDisputeReason(state, value))
                )

            .AddRemainingFields()
            .Confirm("I have the following reasons for raising dispute against this Invoice and I am ready to submit your message. {BODISPUTEREASONOPTIONS}  Shall I go ahead? ")
            .OnCompletion(processARCollRaiseDisputeSave)
            .Message("Thank you");

        form = builder.Build();

        return form;



    }

}

0 ответов

Другие вопросы по тегам