[英]Bot acts differently in Microsoft Teams
I've deployed my Bot to Webchat, Skype and MS Teams. 我已将我的Bot部署到Webchat,Skype和MS团队。
In OnTurnAsync
method I check, if the user input begins with bnr
then I call a specific method. 在OnTurnAsync
方法中我检查,如果用户输入以bnr
开头,那么我调用一个特定的方法。
if (turnContext.Activity.Text.ToLower().StartsWith("bnr"))
{
string msg = RequestHandler.BnrCaller(turnContext.Activity.Text);
await turnContext.SendActivityAsync(msg);
return;
}
It works fine with Skype and Webchat but with teams it does not work 100%, It works just sometimes. 它适用于Skype和Webchat,但是对于团队而言,它不能100%工作,它有时会起作用。
[Edit] [编辑]
I found out, that it does not work if I copied the input into the input field but when I type it, it works fine! 我发现,如果我将输入复制到输入字段但是当我输入它时,它不起作用,它工作正常!
The Messages coming from the Teams are having a different structure. 来自团队的消息具有不同的结构。 The message text begins with the words <at>...</at>
. 消息文本以<at>...</at>
开头。 You need to delete this beginning in a Middleware component, etc. Try to look at your incoming messages through NGROK at localhost:4040 in your web browser. 您需要在中间件组件等中删除此开头。尝试通过Web浏览器中的localhost:4040通过NGROK查看传入消息。
So, I found out the issue by dint of app-insights. 所以,我通过app-insights发现了这个问题。
I've added a middleware
, which logs the request body into app-insights and just realized, that when I copy/paste a message like: "Hello", it would be logged in app-insights as something like this "\\r\\n\\n\\rHello\\r\\n\\n\\r\\n". 我添加了一个middleware
,它将请求正文记录到app-insights中,并且意识到,当我复制/粘贴一条消息时,如“Hello”,它将被记录在app-insight中,就像这样的东西“\\ r \\” ñ\\ n \\ rHello \\ r \\ n \\ n \\ r \\ n”。 When I type it, it would be logged just fine. 当我输入它时,它会记录得很好。 So I jsut remove these symboles from the request and it works! 所以我jsut从请求中删除这些符号,它的工作原理!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.