Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Typing indicator for bot framework in C#

Tags:

botframework

I have a bot in Bot framework. Once user responds to the bot and bot is processing it, I want to show the typing indicator to the user in the meanwhile.

It is possible in Nodejs here - https://docs.microsoft.com/en-us/bot-framework/nodejs/bot-builder-nodejs-send-typing-indicator

But how can I implement it in C#?

like image 574
dang Avatar asked Dec 19 '17 15:12

dang


2 Answers

You have to send an activity of type Typing.

You can do it like that:

// Send "typing" information
Activity reply = activity.CreateReply();
reply.Type = ActivityTypes.Typing;
reply.Text = null;
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await connector.Conversations.ReplyToActivityAsync(reply);
like image 87
Nicolas R Avatar answered Sep 17 '22 11:09

Nicolas R


You can also create the message using context.MakeMessage if you need to instantly respond in MessageReceivedAsync of a dialog.

var typingMsg = context.MakeMessage();
typingMsg.Type = ActivityTypes.Typing;
typingMsg.Text = null;
await context.PostAsync(typingMsg);

The typing indicator is replaced by the next message sent (at least in the Bot Framework emulator). This doesn't seem to work in Slack.

like image 35
Sounten Avatar answered Sep 18 '22 11:09

Sounten