Example #1
0
 private void SendTypingIndicator()
 {
     if (typing == null)
     {
         typing      = activity.CreateReply();
         typing.Type = ActivityTypes.Typing;
     }
     context.SendActivityAsync(typing);
 }
Example #2
0
        private Activity HandleSystemMessage(Activity activity)
        {
            var client = new ConnectorClient(new Uri(activity.ServiceUrl),
                                             new MicrosoftAppCredentials());
            var reply = activity.CreateReply();

            switch (activity.GetActivityType())
            {
            case ActivityTypes.ConversationUpdate:
                IConversationUpdateActivity update = activity;
                if (update.MembersAdded != null && update.MembersAdded.Any())
                {
                    foreach (var newMember in update.MembersAdded)
                    {
                        if (newMember.Id != activity.Recipient.Id)
                        {
                            reply.Text = $"Welcome {newMember.Name}!";
                            client.Conversations.ReplyToActivityAsync(reply);
                        }
                    }
                }
                break;

            case ActivityTypes.ContactRelationUpdate:
                IContactRelationUpdateActivity relationUpdate = activity;
                reply.Text = "RelationUpdate";
                client.Conversations.ReplyToActivityAsync(reply);
                break;

            case ActivityTypes.Typing:
                ITypingActivity typing = activity;
                reply.Text = "Typing";
                client.Conversations.ReplyToActivityAsync(reply);
                break;

            case ActivityTypes.DeleteUserData:
            case ActivityTypes.Ping:
                break;

            default:
                Trace.TraceError($"Unknown activity type ignored: {activity.GetActivityType()}");
                break;
            }
            return(null);
        }
        public static Activity BuildTypingActivity(this Activity userActivity)
        {
            ITypingActivity replyActivity = Activity.CreateTypingActivity();

            replyActivity.ReplyToId = userActivity.Id;
            replyActivity.From      = new ChannelAccount
            {
                Id   = userActivity.Recipient.Id,
                Name = userActivity.Recipient.Name
            };
            replyActivity.Recipient = new ChannelAccount
            {
                Id   = userActivity.From.Id,
                Name = userActivity.From.Name
            };
            replyActivity.Conversation = new ConversationAccount
            {
                Id      = userActivity.Conversation.Id,
                Name    = userActivity.Conversation.Name,
                IsGroup = userActivity.Conversation.IsGroup
            };

            return((Activity)replyActivity);
        }
Example #4
0
 public Task Activity(ITypingActivity activity)
 {
     return(methods.Activity(activity));
 }
 void HandleTyping(ITypingActivity activity)
 {
     // user has started typing, but hasn't submitted message yet
 }