botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Skype For Business] Encoding issues with spaces in messages sent from bot

Open vijaysaimutyala opened this issue 8 years ago • 13 comments

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.

vijaysaimutyala avatar Apr 25 '18 13:04 vijaysaimutyala

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 avatar Apr 25 '18 23:04 EricDahlvang

@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.

vijaysaimutyala avatar May 22 '18 15:05 vijaysaimutyala

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.

EricDahlvang avatar May 25 '18 18:05 EricDahlvang

Hi,

Same problem here. Any update, solution or workaround on this?

Thanks

nikosalexakis avatar Jun 08 '18 21:06 nikosalexakis

Fixed this issue in C# using System.Web, Below is the code

string unicodeString = "&#160 ;            Test       Data     123456 ";

        string decodedText = HttpUtility.HtmlDecode(unicodeString);

Used HtmlDecode method available in HttpUtility Class.

AbhishekSinha02 avatar Jun 18 '18 06:06 AbhishekSinha02

Hi

Same issue here. any update. i need node js solution to get only entered text.

Thanks

Basavarajsk1992 avatar Aug 09 '18 06:08 Basavarajsk1992

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);
    }
}); 

Basavarajsk1992 avatar Aug 10 '18 06:08 Basavarajsk1992

Closing due to lack of activity. Please reopen if issues persist.

stevkan avatar Sep 17 '18 17:09 stevkan

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

ycjuanesteban avatar Sep 25 '18 16:09 ycjuanesteban

Hi,

Same problem here. Any update, solution or workaround on this?

Thanks

bundai223 avatar Oct 15 '18 02:10 bundai223

Workarounds for both C# and node are explained above.

EricDahlvang avatar Oct 15 '18 16:10 EricDahlvang

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

ycjuanesteban avatar Oct 15 '18 23:10 ycjuanesteban

@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

bundai223 avatar Oct 16 '18 08:10 bundai223