コード例 #1
0
        private Activity HandleSystemMessage(Activity message)
        {
            if (message.Type == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (message.Type == ActivityTypes.ConversationUpdate)
            {
                IConversationUpdateActivity update = message;
                var client = new ConnectorClient(new Uri(message.ServiceUrl), new MicrosoftAppCredentials());
                if (update.MembersAdded != null && update.MembersAdded.Any())
                {
                    foreach (var newMember in update.MembersAdded)
                    {
                        if (newMember.Id != message.Recipient.Id)
                        {
                            var init = new List <Attachment>()
                            {
                                SettingsCardDialog.CardIntranet().ToAttachment(),
                                 SettingsCardDialog.CardInfColaborador().ToAttachment(),
                                 SettingsCardDialog.CardSolucionesTI().ToAttachment(),
                            };


                            var reply = message.CreateReply();
                            reply.Text = $"¡Hola, soy Merlí! el asistente virtual del BRITANICO. Permíteme ayudarte en los siguientes temas:";
                            //reply = message.CreateReply();
                            reply.Attachments      = init;
                            reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
                            client.Conversations.ReplyToActivityAsync(reply);
                        }
                    }
                }
            }
            else if (message.Type == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (message.Type == ActivityTypes.Typing)
            {
                ConnectorClient connector = new ConnectorClient(new Uri(message.ServiceUrl));
                Activity        reply     = message.CreateReply();
                reply.Type = ActivityTypes.Typing;
                reply.Text = "...";
                connector.Conversations.ReplyToActivityAsync(reply);
                // Handle knowing tha the user is typing
            }
            else if (message.Type == ActivityTypes.Ping)
            {
            }

            return(null);
        }
コード例 #2
0
ファイル: MainDialog.cs プロジェクト: picty88/PictyBot
        private async Task CardCarousel(IDialogContext context)
        {
            var message = context.MakeMessage();

            message.Attachments      = new List <Attachment>();
            message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            message.Attachments.Add(SettingsCardDialog.CardIntranet().ToAttachment());
            message.Attachments.Add(SettingsCardDialog.CardInfColaborador().ToAttachment());
            message.Attachments.Add(SettingsCardDialog.CardSolucionesTI().ToAttachment());
            message.Text = $"Permíteme ayudarte en los siguientes temas.";
            await context.PostAsync(message);

            context.Wait(this.MessageReceivedAsync);
        }
コード例 #3
0
        public async Task ResumeAfter(IDialogContext context)
        {
            var message = context.MakeMessage();

            message.Attachments      = new List <Attachment>();
            message.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            message.Attachments.Add(SettingsCardDialog.CardIntranet().ToAttachment());
            message.Attachments.Add(SettingsCardDialog.CardInfColaborador().ToAttachment());
            message.Attachments.Add(SettingsCardDialog.CardSolucionesTI().ToAttachment());
            // message.Text = $"Te puedo ayudar con las siguientes opciones.";
            await context.PostAsync(message);

            context.Wait(this.MessageReceivedAsync);
        }