Created
December 14, 2017 14:26
-
-
Save jrmcdona/99df41287852c84f07006ab422898160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace SkypeChatBot.Dialogs | |
{ | |
using Microsoft.Bot.Builder.Dialogs; | |
using System; | |
using System.Threading.Tasks; | |
using Microsoft.Bot.Connector; | |
[Serializable] | |
public class WelcomeDialog : IDialog<string> | |
{ | |
public async Task StartAsync(IDialogContext context) | |
{ | |
await context.PostAsync("Welcome to Xbox Ambassador chat. Please type your question below."); | |
context.Wait(this.MessageReceivedAsync); | |
} | |
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) | |
{ | |
var message = await result; | |
/* If the message returned is a valid name, return it to the calling dialog. */ | |
if ((message.Text != null) && (message.Text.Trim().Length > 5)) | |
{ | |
/* Completes the dialog, removes it from the dialog stack, and returns the result to the parent/calling | |
dialog. */ | |
context.Done(message.Text); | |
} | |
/* Else, try again by re-prompting the user. */ | |
else | |
{ | |
await context.PostAsync("I'm sorry, I don't understand your reply. What is your question (e.g. 'How do I change my gamertag?', 'How can I party chat?')?"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment