Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created July 18, 2016 05:08
Show Gist options
  • Save beachside-project/a1961f422507a66b5c9c4ae481d682e5 to your computer and use it in GitHub Desktop.
Save beachside-project/a1961f422507a66b5c9c4ae481d682e5 to your computer and use it in GitHub Desktop.
EchoCommandDialog
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.Bot.Builder.Dialogs;
using System.Text.RegularExpressions;
namespace DialogDemo.Dialogs
{
public class EchoCommandDialog
{
public static readonly CommandDialog<object> dialog
= new CommandDialog<object>()
.On<bool>(new Regex("^reset"),
async (context, msg) =>
{
PromptDialog.Confirm(context, dialog.ResultHandler, DialogSampleUtil.GetConfirmMessage(nameof(EchoCommandDialog)), BotMessage.NotGetThat);
},
async (context, result) =>
{
var confirm = await result;
if (confirm)
{
DialogSampleUtil.ResetCount(context);
await context.PostAsync(BotMessage.ResetDone);
}
else
{
await context.PostAsync(BotMessage.ResetCancelled);
}
})
.OnDefault<object>(async (context, msg) =>
{
var count = DialogSampleUtil.IncrementCount(context);
var messageActivity = await msg;
await context.PostAsync(DialogSampleUtil.GetIncrementedMessage(count, messageActivity.Text));
context.Wait(dialog.MessageReceived);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment