CiscoDevNet / node-sparkbot

Build Webex ChatBots in JavaScript
https://developer.webex.com/bots.html
MIT License
24 stars 4 forks source link

misinterpretation of bot commands sent from iPhone Spark clients #1

Closed ObjectIsAdvantag closed 7 years ago

ObjectIsAdvantag commented 7 years ago

from Jan Neuzil

"I am currently developping a bot and I have encountered a problem, when you mention the bot from the mobile devices like iPhone, iPad. When you post the message to bot from PC, in the html you have e.g.- html:

'<p><spark-mention data-object-type="person" data-object-id="Y2lzY29xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">SampleBotName</spark-mention> /help</p>'

but when mentioning from mobile device in the html is:

'<spark-mention data-object-id="349xxxxx-xxxx-xxxxx-xxxxxxx" data-object-type="person">SampleBotName</spark-mention> /help'

so there is missing base64 coding. So when using node-sparkbot node.js module, it doesn't fulfill one condition which would remove HTML tag in html parser function resulting in misinterpretation of bot commands. Is this an intended behaviour or it should be the same? Thank you very much.

ObjectIsAdvantag commented 7 years ago

Good point Jan, we'll definitely need to create a workaround in the node-sparkbot library.

I raised this discrepancy among Spark clients to the Spark for Developer team, it's currently being escalated to the Spark clients team. If you're interested to get updates, you can ask devsupport@ciscospark.com to be added to issue 62735:

Background context: the text property cannot safely be used to trim bot mentions, as NickNames (Mentionned participants of the room) vary depending on the list of participants, and the raw text does not provide metadata about where the mentions is exactly. Therefore, the only way to trim the mention is to parse the HTML code. 

Request: we need some alignment and an article on Spark4Devs to explain how to safely trim the bot mention for Cisco Spark.

Here are the examples of how HTML code is generated:

Mac Desktop client: base64 ENCODED person id, AND <p> tag

"text": "hi Steve from the Mac Desktop client",
"html": "<p>hi <spark-mention data-object-type=\"person\" data-object-id=\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS8wM2ZiZTEwOS0yM2Y2LTQ1OWItODFlNS02YzYxM2JhMWNhZTE\">Steve</spark-mention> from the Mac Desktop client</p>",

iPhone native client: base64 DECODED person id, NO <p> tag

"text": "Hi Steve S from my iPhone",
"html": "Hi <spark-mention data-object-id=\"92b3dd9a-675d-4a41-8c41-2abdf89f44f4\" data-object-type=\"person\">Steve S</spark-mention> from my iPhone",

Web client (Chrome Windows): base64 ENCODED person id, NO <p> tag

"text": "hi Valérie from Web client Chome on Windows",
"html": "hi <spark-mention data-object-type=\"person\" data-object-id=\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS84ZjlhYmQ4ZS0yZTJiLTQ5MTYtOGJlZC0wMDMyZjRiYTU3YTM\">Valérie</spark-mention> from Web client Chome on Windows",

Windows desktop client: base64 ENCODED person id, AND <p> tag

"text": "hi Valérie from Windows Desktop",
"html": "<p>hi <spark-mention data-object-type=\"person\" data-object-id=\"Y2lzY29zcGFyazovL3VzL1BFT1BMRS84ZjlhYmQ4ZS0yZTJiLTQ5MTYtOGJlZC0wMDMyZjRiYTU3YTM\">Valérie</spark-mention> from Windows Desktop</p>",
ObjectIsAdvantag commented 7 years ago

Then, in the interpreter both data-object-id and data-object-type need to be searched for in spark-mention

ObjectIsAdvantag commented 7 years ago

published on npm as part of v0.10.1