我正在使用c#.net和LUIS认知服务上的MicrofsoftBotFramework开发一个聊天机器人.
我希望当用户输入时它应该回复为打字或机器人正在输入..
public async TaskPost([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
这段代码也有效,但它将"TYPING"称为动画并转到下一条消息.但我想它应该显示我的消息,我已设置为"Shuttlebot正在打字...
"
大多数频道原生支持"Is Typing"通知.只需将打字活动作为消息发送:
var reply = activity.CreateReply(String.Empty); reply.Type = ActivityTypes.Typing; await activityContext.SendResponse(reply);