Ejemplo n.º 1
0
        private async Task <DialogTurnResult> InterruptAsync(DialogContext innerDc, CancellationToken cancellationToken)
        {
            var cancelMessage = messagesService.Get(MessagesKey.Key.Cancel.ToString());

            if (innerDc.Context.Activity.Type == ActivityTypes.Message)
            {
                var conversation = await conversationStateAccessor.GetAsync(innerDc.Context, () => new ConversationData());

                var luisResult = conversation.LuisResult;

                if (luisResult.TopScoringIntent.Score < 0.9)
                {
                    return(null);
                }

                switch (luisResult.TopScoringIntent.Intent)
                {
                case Luis.Welcome_Intent:
                    await innerDc.Context.SendActivityAsync(HeroCards.Welcome(innerDc.Context.Activity, messagesService));

                    return(await innerDc.CancelAllDialogsAsync());
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            var message = messagesService.Get(MessagesKey.Key.Welcome.ToString());

            foreach (var member in membersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    await turnContext.SendActivityAsync(MessageFactory.Text(message.Value), CancellationToken.None);

                    await turnContext.SendActivityAsync(HeroCards.Welcome((Activity)turnContext.Activity, messagesService));
                }
            }
        }