问题
I am developing a chatbot using MicrofsoftBotFramework on c#.net and LUIS cognitive services.
I want when user type it should reply as typing or bot is typing..
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
Trace.TraceInformation($"Type={activity.Type} Text={activity.Text}");
if (activity.Type == ActivityTypes.Message)
{
//await Microsoft.Bot.Builder.Dialogs.Conversation.SendAsync(activity, () => new ContactOneDialog());
//Implementation of typing indication
ConnectorClient connector = new ConnectorClient(new System.Uri(activity.ServiceUrl));
Activity isTypingReply = activity.CreateReply("Shuttlebot is typing...");
isTypingReply.Type = ActivityTypes.Typing;
await connector.Conversations.ReplyToActivityAsync(isTypingReply);
await Conversation.SendAsync(activity, () =>
new ExceptionHandlerDialog<object>(new ShuttleBusDialog(), displayException: true));
}
else
{
HandleSystemMessage(activity);
}
var response = Request.CreateResponse(System.Net.HttpStatusCode.OK);
return response;
}
This code is working also but it says "TYPING" as animation and goes to next message. But I want it should show my message which I have set as "Shuttlebot is typing...

回答1:
Most of the channels natively support "Is Typing" notifications. Just send the Typing Activity as a message:
var reply = activity.CreateReply(String.Empty);
reply.Type = ActivityTypes.Typing;
await activityContext.SendResponse(reply);
回答2:
If you're trying to send the 'typing' status from the controller, the following may be of some help:
var reply = activity.CreateReply(String.Empty);
reply.Type = ActivityTypes.Typing;
ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));
await connector.Conversations.ReplyToActivityAsync(reply);
Place the above code before the work your controller is trying to do. i.e.
await Conversation.SendAsync(activity, () => new RootDialog());
来源:https://stackoverflow.com/questions/41553491/reply-with-is-typing-message-in-microsoft-botframework