Example #1
0
 public static async Task ReplyWithGreeting(ITurnContext context)
 {
     await context.SendActivity($"Hello, I'm the alarmbot.");
 }
Example #2
0
 public static async Task ReplyWithStartTopic(ITurnContext context)
 {
     await context.SendActivity($"Ok, let's add an alarm.");
 }
Example #3
0
 public static async Task ReplyWithConfused(ITurnContext context)
 {
     await context.SendActivity($"I am sorry, I didn't understand: {context.Activity.AsMessageActivity().Text}.");
 }
Example #4
0
        public async Task OnTurn(ITurnContext context)
        {
            //if (context.Activity.Type == ActivityTypes.ConversationUpdate)
            //{
            //    var newUserName = context.Activity.MembersAdded.FirstOrDefault()?.Name;
            //    if (!string.Equals("Bot", newUserName))
            //    {
            //        //await dialogCtx.Begin("addUserInfo");
            //    }
            //}

            if (context.Activity.Type == ActivityTypes.Message)
            {
                var state = context.GetConversationState <Dictionary <string, object> >();

                var dialogCtx = _dialogs.CreateContext(context, state);

                await dialogCtx.Continue();

                var message      = context.Activity.Text.Trim();
                var indexOfSpace = message.IndexOf(" ", StringComparison.Ordinal);
                var command      = indexOfSpace != -1 ? message.Substring(0, indexOfSpace).ToLower() : message.ToLower();

                switch (command)
                {
                case "tobase64":

                    context.Activity.Text = indexOfSpace >= 0
                            ? context.Activity.Text.Substring(indexOfSpace + 1, message.Length - indexOfSpace - 1)
                            : String.Empty;
                    await dialogCtx.Begin("tobase64");

                    break;

                case "frombase64":

                    context.Activity.Text = indexOfSpace >= 0
                            ? context.Activity.Text.Substring(indexOfSpace + 1, message.Length - indexOfSpace - 1)
                            : String.Empty;
                    await dialogCtx.Begin("frombase64");

                    break;

                case "cards":
                    context.Activity.Text = indexOfSpace >= 0
                            ? context.Activity.Text.Substring(indexOfSpace + 1, message.Length - indexOfSpace - 1)
                            : String.Empty;
                    await dialogCtx.Begin("cards");

                    break;

                case "langdetect":
                    context.Activity.Text = indexOfSpace >= 0
                            ? context.Activity.Text.Substring(indexOfSpace + 1, message.Length - indexOfSpace - 1)
                            : String.Empty;
                    await dialogCtx.Begin("langdetect");

                    break;

                default:
                    if (!context.Responded)
                    {
                        var result = context.Services.Get <RecognizerResult>
                                         (LuisRecognizerMiddleware.LuisRecognizerResultKey);
                        var intent = result?.GetTopScoringIntent();
                        if (intent != null)
                        {
                            switch (intent.Value.intent.ToLower())
                            {
                            case "hello":
                                await context.SendActivity($"Hello, {context.Activity.From.Name}!");

                                break;

                            case "play_music":
                                await context.SendActivity($"La la la...la-la-la-la...la");

                                break;

                            case "stop_music":
                                await context.SendActivity($"No more music!");

                                break;

                            default:
                                await context.SendActivity($"Вашу команду не удалось распознать.");

                                break;
                            }
                        }
                    }

                    break;
                }
            }
        }
 public async Task OnTurn(ITurnContext turnContext)
 {
     await turnContext.SendActivity($"Hello there from {turnContext.Activity.Type}");
 }
Example #6
0
 public static async Task ReplyWithShowAlarms(ITurnContext context, dynamic data)
 {
     await context.SendActivity(AlarmsCard(context, data, "Alarms", null));
 }
Example #7
0
        private async Task GetDiscountsHandler(ITurnContext context)
        {
            var msg = "This week we have a 25% discount in all of our wine selection";

            await context.SendActivity(msg);
        }
 public static void ReplyWithHelp(ITurnContext context)
 {
     context.SendActivity($"Any text you enter will be sent to LUIS and we will return matching intents and entities.");
 }
Example #9
0
        public async Task OnTurn(ITurnContext context)
        {
            if (context.Activity.Type is ActivityTypes.Message)
            {
                var message = context.Activity.AsMessageActivity();
                // Get the intent recognition result from the context object.
                var              dispatchResult = context.Services.Get <RecognizerResult>(LuisRecognizerMiddleware.LuisRecognizerResultKey) as RecognizerResult;
                var              topIntent = dispatchResult?.GetTopScoringIntent();
                LuisRecognizer   luisRecognizer1, luisRecognizer2;
                RecognizerResult recognizerResult;

                var intentsList = new List <string>();
                var entitiesList = new List <string>();

                if (topIntent == null)
                {
                    await context.SendActivity("Unable to get the top intent.");
                }
                else
                {
                    if (topIntent.Value.score < 0.3)
                    {
                        await context.SendActivity("I'm not very sure what you want but will try to send your request.");
                    }
                    switch (topIntent.Value.intent.ToLowerInvariant())
                    {
                    case "l_homeautomation":
                        await context.SendActivity("Sending your request to the home automation system ...");

                        luisRecognizer1  = new LuisRecognizer(luisModel1);
                        recognizerResult = await luisRecognizer1.Recognize(message.Text, System.Threading.CancellationToken.None);

                        // list the intents
                        foreach (var intent in recognizerResult.Intents)
                        {
                            intentsList.Add($"'{intent.Key}', score {intent.Value}");
                        }
                        await context.SendActivity($"Intents detected by the home automation app:\n\n{string.Join("\n\n", intentsList)}");

                        // list the entities
                        entitiesList = new List <string>();
                        foreach (var entity in recognizerResult.Entities)
                        {
                            if (!entity.Key.ToString().Equals("$instance"))
                            {
                                entitiesList.Add($"{entity.Key}: {entity.Value.First}");
                            }
                        }

                        if (entitiesList.Count > 0)
                        {
                            await context.SendActivity($"The following entities were found in the message:\n\n{string.Join("\n\n", entitiesList)}");
                        }

                        // Here, you can add code for calling the hypothetical home automation service, passing in any entity information that you need

                        break;

                    case "l_weather":
                        await context.SendActivity("Sending your request to the weather system ...");

                        luisRecognizer2  = new LuisRecognizer(luisModel2);
                        recognizerResult = await luisRecognizer2.Recognize(message.Text, System.Threading.CancellationToken.None);

                        // list the intents
                        var intentsResult2 = new List <string>();
                        foreach (var intent in recognizerResult.Intents)
                        {
                            intentsResult2.Add($"'{intent.Key}', score {intent.Value}");
                        }
                        await context.SendActivity($"Intents detected by the weather app: \n\n{string.Join("\n\n", intentsResult2)}");

                        // list the entities
                        entitiesList = new List <string>();
                        foreach (var entity in recognizerResult.Entities)
                        {
                            if (!entity.Key.ToString().Equals("$instance"))
                            {
                                entitiesList.Add($"{entity.Key}: {entity.Value.First}");
                            }
                        }

                        if (entitiesList.Count > 0)
                        {
                            await context.SendActivity($"The following entities were found in the message:\n\n{string.Join("\n\n", entitiesList)}");
                        }

                        // Here, you can add code for calling the hypothetical weather service, passing in any entity information that you need

                        break;

                    case "none":
                    // You can provide logic here to handle the known None intent (none of the above).
                    // In this example we fall through to the QnA intent.
                    case "q_faq":
                        QnAMaker qnaMaker        = new QnAMaker(qnaOptions);
                        var      messageActivity = context.Activity.AsMessageActivity();
                        if (!string.IsNullOrEmpty(messageActivity.Text))
                        {
                            var results = await qnaMaker.GetAnswers(messageActivity.Text.Trim()).ConfigureAwait(false);

                            if (results.Any())
                            {
                                await context.SendActivity(results.First().Answer);
                            }
                            else
                            {
                                await context.SendActivity("Couldn't find an answer in the FAQ.");
                            }
                        }
                        break;

                    default:
                        // The intent didn't match any case, so just display the recognition results.
                        await context.SendActivity($"Dispatch intent: {topIntent.Value.intent} ({topIntent.Value.score}).");

                        break;
                    }
                }
            }
            else if (context.Activity.Type is ActivityTypes.ConversationUpdate)
            {
                foreach (var newMember in context.Activity.MembersAdded)
                {
                    if (newMember.Id != context.Activity.Recipient.Id)
                    {
                        await context.SendActivity("Hello and welcome to the LUIS Dispatch sample bot. This bot dispatches messages to LUIS apps and QnA, using a LUIS model generated by the Dispatch tool in hierarchical mode.");
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// Every Conversation turn for our YellowDuckyBot will call this method. In here
        /// the bot checks the Activity type to verify it's a message, bumps the
        /// turn conversation 'Turn' count, and then echoes the users typing
        /// back to them.
        /// </summary>
        /// <param name="context">Turn scoped context containing all the data needed
        /// for processing this conversation turn. </param>
        public async Task OnTurn(ITurnContext context)
        {
            // TODO: MOVE OUTSIDE THE CLASS IN MEMORY MODULE
            var ping = false;

            //Prepared response to send back to user
            string response = null;//context.Activity.Text;

            // This bot is only handling Messages
            if (context.Activity.Type == ActivityTypes.Message)
            {
                //Read it as lower case - will be better
                var contextQuestion = context.Activity.Text.ToLower();

                //Old simple game of Lycopersicon
                var playingLycopersiconResult = _mind.Facts.Read("playingLycopersicon");
                if (playingLycopersiconResult != null &&
                    playingLycopersiconResult.Equals("true") &&
                    !contextQuestion.StartsWith("lycopersicon"))
                {
                    response = "Lycopersicon";
                    await context.SendActivity(response);

                    return;
                }
                else
                {
                    //Load retorts from JSON file
                    response = _mind.Respond(contextQuestion);
                    if (response != null)
                    {
                        await context.SendActivity(response);

                        return;
                    }

                    // Get the conversation state from the turn context
                    var state = context.GetConversationState <EchoState>();

                    // Bump the turn count.
                    state.TurnCount++;

                    // Check for add retort - from original, not lower case
                    // TODO ADD ADMIN MODE
                    if (contextQuestion.StartsWith("simonsays"))
                    {
                        if (contextQuestion.StartsWith("simonsays addretort;"))
                        {
                            var split = context.Activity.Text.Split(";");
                            if (split.Length == 3)
                            {
                                if (split[1].Trim().Length > 0 && split[2].Trim().Length > 0)
                                {
                                    //TODO CHECK, IF RETORT ALREADY EXISTS
                                    var result = _mind.AddRetort(split[1].Trim(), split[2].Trim());
                                    response = result
                                        ? $"Added new retort {split[1]}."
                                        : $"Couldn't add retort {split[1]}.";
                                }
                                else
                                {
                                    response = "One of parameters was empty.";
                                }
                            }
                            else
                            {
                                response = "It should follow pattern: simonsays addretort;question;answer";
                            }

                            await context.SendActivity(response);

                            return;
                        }
                        else if (contextQuestion.StartsWith("simonsays SPLIT;"))
                        {
                            var split = context.Activity.Text.Split(";");
                            foreach (var word in split)
                            {
                                //var result = AddRetort(context.Activity.Text);
                                response = word;
                                //response = result.StartsWith("Couldn't") ? "[ERROR] " + result : result;
                                await context.SendActivity(response);
                            }
                        }
                    }

                    //Facts
                    // TODO Move this to mind
                    if (contextQuestion.Contains("fact"))
                    {
                        if (contextQuestion.StartsWith("addfact"))
                        {
                            var daFact = context.Activity.Text.Split(" ");
                            if (daFact.Length > 2)
                            {
                                // Omit first one as it is a command
                                var factName  = daFact[1].ToLower();
                                var factValue = daFact[2];
                                //TODO Add processing and concatenation, if fact is longer, than just one word.
                                var result = _mind.Facts.Add(factName, factValue);
                                response = result
                                    ? $"Fact {factName} was added."
                                    : $"Fact {factName} couldn't be added.";
                                await context.SendActivity(response);

                                return;
                            }
                        }
                        else if (contextQuestion.StartsWith("readfact"))
                        {
                            var daFact = contextQuestion.Split(" ");
                            if (daFact.Length == 2)
                            {
                                // Omit first one as it is a command
                                var factName = daFact[1];
                                var result   = _mind.Facts.Read(factName);
                                response = result != null
                                    ? $"Fact {factName} is {result}."
                                    : $"Fact {factName} doesn't exist.";
                                await context.SendActivity(response);

                                return;
                            }
                        }
                        else if (contextQuestion.StartsWith("forgetfact"))
                        {
                            var daFact = contextQuestion.Split(" ");
                            if (daFact.Length == 2)
                            {
                                // Omit first one as it is a command
                                var factName = daFact[1];
                                var result   = _mind.Facts.Remove(factName);
                                response = result
                                    ? $"Fact {factName} was forgotten."
                                    : $"Fact {factName} doesn't exist.";
                                await context.SendActivity(response);

                                return;
                            }
                        }
                        else if (contextQuestion.StartsWith("countfact"))
                        {
                            var daFact = contextQuestion.Split(" ");
                            if (daFact.Length == 1)
                            {
                                // Omit first one as it is a command
                                var count = _mind.Facts.Count();
                                response = $"Facts base contains {count} facts.";
                                await context.SendActivity(response);

                                return;
                            }
                        }
                    }

                    //
                    switch (contextQuestion)
                    {
                    case "hello":
                        response = "Hello to You!";
                        break;

                    // TODO Add some admin-mode with prior authorization
                    // TODO Add console entry level of extending retorts
                    case "how many retorts?":
                        response = $"I've {_mind.CountRetorts()} retorts in my mind.";
                        break;

                    case "ping":
                        ping = true;
                        break;

                    // TODO change it to game of Lycopersicon
                    case "let's play lycopersicon":
                        var playLycopersiconResult = _mind.Facts.Add("playingLycopersicon", "true");
                        response = playLycopersiconResult ? "Ok.. Lycopersicon" : "Hmm.. something is wrong wit that game.";
                        break;

                    case "lycopersicon":
                        playingLycopersiconResult = _mind.Facts.Read("playingLycopersicon");
                        if (playingLycopersiconResult != null && playingLycopersiconResult.Equals("true"))
                        {
                            var stopPlayLycopersiconResult = _mind.Facts.Remove("playingLycopersicon");
                            if (stopPlayLycopersiconResult)
                            {
                                // TODO CANNOT STOP PLAYING..
                                var playedLycopersiconResult = _mind.Facts.Add("playedLycopersicon", "true");
                                response = playedLycopersiconResult ?
                                           "Ha ha, you lost. I'll remember that."
                                        : "Ha ha, you lost... Wait, what just happened?";
                            }
                            else
                            {
                                response = "I cannot stop.. Lycopersicon.";
                            }
                        }
                        else
                        {
                            playLycopersiconResult = _mind.Facts.Add("playingLycopersicon", "true");
                            response = playLycopersiconResult ? "Ok.. Lycopersicon" : "Hmm.. something is wrong wit that game.";
                        }
                        break;

                    case "roll d20":
                        var lastRoll = new Random().Next(1, 20);
                        switch (lastRoll)
                        {
                        //this.count++;
                        case 1:
                            response = $"You rolled {lastRoll}. Critical Failure!";
                            break;

                        case 20:
                            response = $"You rolled {lastRoll}. Critical Success!";
                            break;

                        default:
                            response = $"You rolled {lastRoll}.";
                            break;
                        }
                        break;

                    case "where are you?":
                        response = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                        break;

                    case "what do you see?":
                        //Environment.CurrentDirectory
                        var path  = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"wwwroot\");
                        var files = Directory.GetFiles(path);
                        response = $"Well, I see {files.Length} files around me.";
                        response = files.Aggregate(response, (current, filename) => current + $"\n {filename}");
                        //string[] files = File.ReadAllLines(path);
                        break;

                    default:
                        // TODO log down all given not recognized phrases in order to analyze them in the future and add new phrases
                        response = "I didn't get this one. Can You repeat in simpler words.";
                        break;
                    }
                }

                // Echo back to the user whatever they typed.
                //await context.SendActivity(response);//Turn {state.TurnCount}:
            }
            else if (context.Activity.Type == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (context.Activity.Type == ActivityTypes.ConversationUpdate)
            {
                // Handle conversation state changes, like members being added and removed
                // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
                // Not available in all channels
            }
            else if (context.Activity.Type == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (context.Activity.Type == ActivityTypes.Typing)
            {
                // Handle knowing tha the user is typing
            }
            else if (context.Activity.Type == ActivityTypes.Ping)
            {
                ping = true;
            }

            //if pinged
            if (ping)
            {
                //Add responses in parts with delay in between
                response = "Ping..";
                await context.SendActivity(response);

                await Task.Delay(2000);//wait 2 seconds

                response = "Yup, I'm alive..";
                await context.SendActivity(response);

                await Task.Delay(1500);//wait 2 seconds

                response = "I mean On.";
            }

            //Send response to user
            if (response != null)
            {
                await context.SendActivity(response);
            }
        }
Example #11
0
 public async Task OnTurn(ITurnContext TurnContext)
 {
     await TurnContext.SendActivity("Hey!");
 }
Example #12
0
 public static async Task ReplyWithConfused(ITurnContext context)
 {
     await context.SendActivity($"I am sorry, I didn't understand that.");
 }
Example #13
0
 public static async Task ReplyWithResumeTopic(ITurnContext context)
 {
     await context.SendActivity($"What can I do for you?");
 }
Example #14
0
 public static async Task ReplyWithHelp(ITurnContext context)
 {
     await context.SendActivity($"I can add an alarm, show alarms or delete an alarm. ");
 }
        public async Task HandleGoodbye(ITurnContext context, string messageText, MiddlewareSet.NextDelegate next)
        {
            await context.SendActivity("Bye");

            await next();
        }
Example #16
0
 private Task ShowDefaultMessage(ITurnContext turnContext)
 {
     return(turnContext.SendActivity("'Show Alarms', 'Add Alarm', 'Delete Alarm', 'Help'."));
 }
 public async Task HandleThanks(ITurnContext context, string messageText, MiddlewareSet.NextDelegate next)
 {
     await context.SendActivity("You're welcome.");
 }
Example #18
0
        public async Task OnTurn(ITurnContext context)
        {
            if (context.Activity.Type == ActivityTypes.Message)
            {
                var state = context.GetConversationState <SimplePromptState>();

                // Name prompt
                if (!state.PromptinName && !state.PromptinAge)
                {
                    // Prompt for Name
                    state.PromptinName = true;
                    await namePrompt.Prompt(context, "Hello! What is your name?");
                }
                else if (state.PromptinName)
                {
                    // Attempt to recognize the user name
                    var name = await namePrompt.Recognize(context);

                    if (!name.Succeeded())
                    {
                        // Not recognized, re-prompt
                        await namePrompt.Prompt(context, "Sorry, I didn't get that. What is your name?");
                    }
                    else
                    {
                        // Save name and set next state
                        state.Name         = name.Value;
                        state.PromptinName = false;
                    }
                }

                // Age Prompt
                if (!string.IsNullOrEmpty(state.Name) && state.Age == 0)
                {
                    // Prompt for age
                    if (!state.PromptinAge)
                    {
                        state.PromptinAge = true;
                        await agePrompt.Prompt(context, $"How old are you, {state.Name}?");
                    }
                    else
                    {
                        var age = await agePrompt.Recognize(context);

                        if (!age.Succeeded())
                        {
                            // Not recognized, re-prompt
                            await agePrompt.Prompt(context, "Sorry, that doesn't look right. Ages 13 to 90 only. What is your age?");
                        }
                        else
                        {
                            // Save age and continue
                            state.Age         = age.Value;
                            state.PromptinAge = false;
                        }
                    }
                }

                // Display provided information (if complete)
                if (!string.IsNullOrEmpty(state.Name) && state.Age != 0)
                {
                    await context.SendActivity($"Hello {state.Name}, You are {state.Age}.");

                    // Reset sample by clearing state
                    state.Name = null;
                    state.Age  = 0;
                }
            }
        }
Example #19
0
 public static async Task RunAsync([BotTrigger] ITurnContext turnContext, TraceWriter log)
 {
     await turnContext.SendActivity("Hello World!");
 }
 public static void ReplyWithGreeting(ITurnContext context)
 {
     context.SendActivity($"Hello, Let's discover what you can do with cards.");
 }
Example #21
0
        public async Task OnTurn(ITurnContext context)
        {
            //TODO: is this the right way to handle cards?
            string  utterance = context.Activity.Text;
            JObject cardData  = (JObject)context.Activity.Value;

            if (cardData != null && cardData.Property("intent") != null)
            {
                utterance = cardData["utterance"].ToString();
            }

            var userState         = context.GetUserState <CafeBotUserState>();
            var conversationState = context.GetConversationState <CafeBotConvState>();

            switch (context.Activity.Type)
            {
            case ActivityTypes.ConversationUpdate:
                var newUserName = context.Activity.MembersAdded[0].Name;
                if (!string.IsNullOrWhiteSpace(newUserName) && newUserName != "Bot" && string.IsNullOrEmpty(userState.name))
                {
                    await context.SendActivity($"Hello {newUserName}! I'm the Cafe bot!");

                    // remember the user's name
                    userState.name = newUserName;

                    userState.sendCards = true;

                    await context.SendActivity("I can help you find contoso cafe locations, book a table and answer questions about Contoso cafe!");

                    // send a welcome card
                    if (userState.sendCards)
                    {
                        await context.SendActivity(CreateCardResponse(context.Activity, createWelcomeCardAttachment()));
                    }
                }
                break;

            case ActivityTypes.Message:

                // create dialogContext
                var dc = _dialogs.CreateContext(context, conversationState);
                // continue with any active dialogs
                await dc.Continue();

                if (!context.Responded)
                {
                    // top level dispatch
                    switch (utterance)
                    {
                    case "hi":
                        await context.SendActivity("Hello, I'm the contoso cafe bot. How can I help you?");

                        if (userState.sendCards)
                        {
                            await context.SendActivity(CreateCardResponse(context.Activity, createWelcomeCardAttachment()));
                        }
                        break;

                    case "book table":
                        await dc.Begin("BookTable");

                        break;

                    case "who are you?":
                        await dc.Begin("WhoAreYou");

                        break;

                    default:
                        await context.SendActivity("Sorry, I do not understand.");

                        await context.SendActivity("You can say hi or book table or find locations");

                        break;
                    }
                }
                break;
            }
        }
 public static void ReplyWithResumeTopic(ITurnContext context)
 {
     context.SendActivity($"What can I do for you?");
 }
Example #23
0
        public async Task OnTurn(ITurnContext context)
        {
            if (context.Activity.Type == ActivityTypes.Message)
            {
                //if the message is proxied between users, then do not treat it as a normal reservation message
                if (!await ChatProxied(context))
                {
                    //scuba bot allows entering text, or interacting with the card
                    string text = string.IsNullOrEmpty(context.Activity.Text) ? string.Empty : context.Activity.Text.ToLower();

                    IMessageActivity nextMessage = null;

                    if (!string.IsNullOrEmpty(text))
                    {
                        nextMessage = await GetMessageFromText(context, context.Activity, text);
                    }

                    if (nextMessage == null)
                    {
                        nextMessage = await GetNextScubaMessage(context, context.Activity);
                    }

                    await context.SendActivity(nextMessage);
                }
            }
            else if (context.Activity.Type == ActivityTypes.ConversationUpdate && context.Activity.ChannelId != Channels.Directline)
            {
                IConversationUpdateActivity iConversationUpdated = context.Activity as IConversationUpdateActivity;
                if (iConversationUpdated != null)
                {
                    foreach (var member in iConversationUpdated.MembersAdded ?? System.Array.Empty <ChannelAccount>())
                    {
                        // if the bot is added, then show welcome message
                        if (member.Id == iConversationUpdated.Recipient.Id)
                        {
                            var reply = await context.Activity.GetReplyFromCardAsync("0-Welcome");

                            await context.SendActivity(reply);
                        }
                    }
                }
            }
            else if (context.Activity.Type == ActivityTypes.Event && context.Activity.Name == "WelcomeRequest")
            {
                var reply = await context.Activity.GetReplyFromCardAsync("0-Welcome");

                await context.SendActivity(reply);
            }
            else if (context.Activity.Type == ActivityTypes.Event && context.Activity.Name == "proxyWelcomeRequest")
            {
                var channelData = context.Activity.ChannelData as JObject;
                if (channelData != null)
                {
                    //messages with a "chatwithuserid" in channel data are from a Contoso Scuba instructor, chatting a person who has made a new reservation
                    JToken userIdToken = null;
                    if (channelData.TryGetValue("chatwithuserid", out userIdToken))
                    {
                        var userName = ReservationSubscriptionService.GetUserName(userIdToken.ToString());
                        var reply    = context.Activity.CreateReply($"You are now messaging: {userName} ");
                        await context.SendActivity(reply);
                    }
                }
            }
        }
 public static void ReplyWithConfused(ITurnContext context)
 {
     context.SendActivity($"I am sorry, I didn't understand that.");
 }
Example #25
0
 /// <summary>
 /// Sends a message to the user, using the context for the current turn.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <param name="activity">The message activity to send.</param>
 /// <returns>A task that represents the work queued to execute.</returns>
 public async Task Prompt(ITurnContext context, IMessageActivity activity)
 {
     await context.SendActivity(activity);
 }
 public async Task HandleGreeting(ITurnContext context, string messageText, MiddlewareSet.NextDelegate next)
 {
     await context.SendActivity("Well hello there. What can I do for you today?");
 }
Example #27
0
 public static async Task ReplyWithHelp(ITurnContext context, Alarm alarm = null)
 {
     await context.SendActivity($"I am working with you to create an alarm.  To do that I need to know the title and time.\n\n{AlarmDescription(context, alarm)}");
 }
 public async Task HandleStatusRequest(ITurnContext context, string messageText, MiddlewareSet.NextDelegate next)
 {
     await context.SendActivity("I am great.");
 }
Example #29
0
 public static async Task ReplyWithCancelPrompt(ITurnContext context, Alarm alarm)
 {
     await context.SendActivity(ResponseHelpers.ReplyWithSuggestions(context, "Cancel Alarm?", $"Did you want to cancel the alarm?\n\n{AlarmDescription(context, alarm)}", YesNo));
 }
 public static async Task ReplyWithHelp(ITurnContext context)
 {
     await context.SendActivity($"You can guess or show guesses.");
 }