会話が 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."));
}
}
}
[シリアライズ可能] public class 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;
}
}