Created
December 14, 2017 14:27
-
-
Save jrmcdona/5908e71e691b3bef73ad1604cce5e3cf 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 System; | |
using System.Threading.Tasks; | |
using System.Text; | |
using Microsoft.Bot.Builder.Dialogs; | |
using Microsoft.Bot.Connector; | |
#pragma warning disable 1998 | |
[Serializable] | |
public class RootDialog : IDialog<object> | |
{ | |
private string question = null; | |
public async Task StartAsync(IDialogContext context) | |
{ | |
context.Wait(this.MessageReceivedAsync); | |
} | |
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) | |
{ | |
var message = await result; | |
if (this.question == null) | |
{ | |
await this.SendWelcomeMessageAsync(context); | |
} | |
else | |
{ | |
context.Wait(this.MessageReceivedAsync); | |
} | |
} | |
private async Task SendWelcomeMessageAsync(IDialogContext context) | |
{ | |
context.Call(new WelcomeDialog(), this.WelcomeDialogResumeAfter); | |
} | |
private async Task WelcomeDialogResumeAfter(IDialogContext context, IAwaitable<string> result) | |
{ | |
try | |
{ | |
this.question = await result; | |
StringBuilder strReplyMessage = new StringBuilder(); | |
strReplyMessage.Append($"Thank you, we are searching for a community volunteer to help."); | |
strReplyMessage.Append($"\n"); | |
strReplyMessage.Append($"Please standby."); | |
await context.PostAsync(strReplyMessage.ToString()); | |
//context.Call(new AgeDialog(this.name), this.AgeDialogResumeAfter); | |
} | |
catch (TooManyAttemptsException) | |
{ | |
await context.PostAsync("I'm sorry, I'm having issues understanding you. Let's try again."); | |
context.Call(new WelcomeDialog(), this.WelcomeDialogResumeAfter); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment