Search code examples
javascriptazurebotframeworkchatbotmicrosoft-teams

Botframework on MS teams: copy paste input not parsed to the backened


In our chatbot, we are using MS botframework as front-end. One of the main channel we are using MS teams.

Whenever a user is copying pasting text in MS teams, in the backend we are not receiving the same message. We get to see "text/html Error undefined", on the surface everything looks alright, but in backened we get this message as utterance. We had tried opening case with MS botframework team but they have pointed us here.


Solution

  • I recommend logging your activity.text from the turn handler so you can see exactly what is getting passed to the backend. We faced a similar issue, though it seemed to manifest only on prompts. I'm putting our solution here in case it helps you. Typically this is because there are a lot of hidden characters (for me it was \r and \n). It's a bit ugly but we solved with the following formatting (also takes care of trailing spaces, probably not a good idea if you might have leading spaces though!):

    str.split(" ").splice(-1)[0].match(/.+/g)[0]

    The .match piece is really what does the work here, as it is matching all non-newline characters. If the newlines are what is causing the issue, this should fix your problem.