[Skype For Business] Encoding issues with spaces in messages sent from bot
Bot Info
- SDK Platform: REST API
- SDK Version:
- Active Channels: Skype For business, Web Chat
- Deployment Environment:
Issue Description
If a user sends a messages with trailing spaces, the spaces are encoded into special characters while sending to the bot like below
Multiple Spaces is received like below:
'hi� � � � \r\n', '
Single space is received like below:
'hi '
I'm not sure what encoding is the message sent from SFB to decode at the bot. My bot is implemented in Python and I tried multiple encoding and decoding pairs which does not work.
Because of this, my bot fails in detecting the exact intent sometimes which results in unexpected behavior for a given intent.
Expected Behavior
Similar to WebChat, it would be nice extra trailing or leading spaces are trimmed and sent to bot.
I've asked the Skype for Business Bots team about this, and I'll get back to you once I've received a response.
@EricDahlvang Any updates on this ? I've found a new issue. I was using SfB 2013 when I posted this issue. Now I've updated to SfB 2016 and now when I send a message, the first message is sent fine as normal text. Once I receive the response from the bot and start sending a second message, the message is sent along with some text formatting information as below.
p.MsoNormal, li.MsoNormal, div.MsoNormal { margin-top:0in; margin-right:0in; margin-bottom:8.0pt; margin-left:0in; line-height:107%; font-size:11.0pt; font-family:"Calibri",sans-serif; }
There already a issue logged here #3712 but its been a while. And a point to note, one of my colleagues use SfB 2016 but a 32 bit version and she does not see such issue when she sends a mesage, the text is passed along fine.
HI @vijaysaimutyala
I'm trying to get someone from the Skype for Business Bots team to address this, and other SfBB issues. I apologize for the delay.
Hi,
Same problem here. Any update, solution or workaround on this?
Thanks
Fixed this issue in C# using System.Web, Below is the code
string unicodeString = "  ; Test Data 123456 ";
string decodedText = HttpUtility.HtmlDecode(unicodeString);
Used HtmlDecode method available in HttpUtility Class.
Hi
Same issue here. any update. i need node js solution to get only entered text.
Thanks
Hi,
I got some solution fro this, and it is working fine for me. If user entered text from Skype for business channel, the text is encode with some additional text. For example: "'\r\n\r\n\r\n\r\n\r\n\r\np.MsoNormal, li.MsoNormal, div.MsoNormal {\nmargin-top:0in;\nmargin-right:0in;\nmargin-bottom:8.0pt;\nmargin-left:0in;\nline-height:107%;\nfont-size:11.0pt;\nfont-family:"Calibri",sans-serif;\n}\n\n.MsoChpDefault {\nfont-family:"Calibri",sans-serif;\n}\n\n.MsoPapDefault {\nmargin-bottom:8.0pt;\nline-height:107%;\n}\n\ndiv.WordSection1 {\n}\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nThank you\r\n\r\n\r\n\r\n\r\n\r\n\r\n'"
From this i need to get only Thank you which is entered by the user. I have done this with some regular express as shown below
function decodtext(text){
text = text.trim();
text = text.replace(/\n/g, '');
text = text.replace(/\r/g, '');
text = text.replace(/ /g, ' ');
var searchLastOf = "}",
rex = new RegExp(searchLastOf + "(?!.*" + searchLastOf + ")", "g"),
idx = text.search(rex);
var str = text.substring(idx+1);
return str;
}
And we need to invoke or we need to remove this additional text before it sends to LUIS recognizer. so we need to invoke this using below part
bot.on('receive', function (event) {
if(event.text && event.type == 'message'){
event.text = decodtext(event.text);
}
});
Closing due to lack of activity. Please reopen if issues persist.
Hi! I'm developing a bot (.net) for S4B and have a similar issue, when the user write anything thing the bot receives the text like this:
p.MsoNormal, li.MsoNormal, div.MsoNormal { margin-top:0cm; margin-right:0cm; margin-bottom:8.0pt; margin-left:0cm; line-height:107%; font-size:11.0pt; font-family:"Calibri",sans-serif; } .MsoChpDefault { font-family:"Calibri",sans-serif; } .MsoPapDefault { margin-bottom:8.0pt; line-height:107%; } div.WordSection1 { } hola
Hi,
Same problem here. Any update, solution or workaround on this?
Thanks
Workarounds for both C# and node are explained above.
Hi,
Same problem here. Any update, solution or workaround on this?
Thanks
Hi, @bundai223 with my team, we descover that this problem is only for a especific lync version and our workaround was update all the lync versions for the last S4B.
And the other thing that you can check is this solution (https://github.com/Microsoft/BotBuilder/issues/4528#issuecomment-411988553) that @EricDahlvang give us like posible solution
@EricDahlvang @ycjuanesteban Thank you for reply! Probably the problem solved in my user's environment.
Unexpected text (like MsoNormal): SfB 16.0.4266.1001 expected simple text: SfB 16.4417.1000