Ejemplo n.º 1
0
        protected override async Task OnMembersAddedAsync(IList <ChannelAccount> membersAdded, ITurnContext <IConversationUpdateActivity> turnContext, CancellationToken cancellationToken)
        {
            foreach (var member in membersAdded)
            {
                if (member.Id != turnContext.Activity.Recipient.Id)
                {
                    var helper      = new HelperCards();
                    var welcomeCard = helper.GetWelcomeCard();

                    var response = ((Activity)turnContext.Activity).CreateReply();
                    var reply    = welcomeCard.GetCard();

                    var result = new Attachment()
                    {
                        ContentType = "application/vnd.microsoft.card.adaptive",
                        Content     = reply
                    };

                    response.Attachments = new List <Attachment>()
                    {
                        result
                    };

                    await turnContext.SendActivityAsync(response, cancellationToken);
                }
            }
        }
Ejemplo n.º 2
0
        protected override async Task OnMessageActivityAsync(ITurnContext <IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            if (turnContext.Activity.Type == turnContext.Activity.Value != null || turnContext.Activity.Value != string.Empty)
            {
                var cardData = JsonConvert.DeserializeObject <JsonDataAux>(turnContext.Activity.Value.ToString());
                var helper   = new HelperCards();

                var          response = ((Activity)turnContext.Activity).CreateReply();
                AdaptiveCard reply;

                if (cardData.Action == "GALLERYIMAGES")
                {
                    var cardResult = helper.GetGalleryCard(Guid.Parse(cardData.Selected));
                    reply = cardResult.GetCard();
                }
                else if (cardData.Action == "VIDEOCARD")
                {
                    var cardResult = helper.GetVideoCard(Guid.Parse(cardData.Selected));
                    reply = cardResult.GetCard();
                }
                else if (cardData.Action == "FORM")
                {
                    var cardResult = helper.GetFormCard(Guid.Parse(cardData.Selected));
                    reply = cardResult.GetCard();
                }
                else if (cardData.Action == "MDZFORM")
                {
                    var _formInfo  = JsonConvert.DeserializeObject <FormMDZModel>(turnContext.Activity.Value.ToString());
                    var cardResult = helper.GetStandardCard(Guid.Parse("d92c1ecb-1752-4ae3-97de-7b4aef61ee6b"));
                    reply = cardResult.GetCard();
                }
                else
                {
                    var cardResult = helper.GetStandardCard(Guid.Parse(cardData.Selected));
                    reply = cardResult.GetCard();
                }

                var result = new Attachment()
                {
                    ContentType = "application/vnd.microsoft.card.adaptive",
                    Content     = reply
                };

                response.Attachments = new List <Attachment>()
                {
                    result
                };

                await turnContext.SendActivityAsync(response, cancellationToken);
            }
            else
            {
                // First, we use the dispatch model to determine which cognitive service (LUIS or QnA) to use.
                var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);

                // Top intent tell us which cognitive service to use.
                var topIntent = recognizerResult.GetTopScoringIntent();

                // Next, we call the dispatcher with the top intent.
                await DispatchToTopIntentAsync(turnContext, topIntent.intent, recognizerResult, cancellationToken);
            }
            //}
        }