node-red-contrib-chatbot
node-red-contrib-chatbot copied to clipboard
MS Teams. Button press in mobile version does not receive in ms teams receive node.
Hello.
When using the desktop version or the web, the user clicks on the button in the card sent by the bot, message comes to the connector(ms teams receiver node) and we can process it.
But if the user uses the mobile version of ms teams - android or iOS, then by pressing the buttons we do not get message at the receiver node(
Press button in mobile version
No message data in consoles ( Debug in receiver node is enable
Hello. This is fixed by sending a card like Adaptive Cards. Then buttons work in the mobile version as well. To do this, you need to change:
In file: lib\platforms\microsoft-teams\index.js Change sender to>
MicrosoftTeams.out('inline-buttons', function(message) {
const card = CardFactory.adaptiveCard({
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "TextBlock",
"text": message.payload.content,
"wrap": true
}
],
"actions": message.payload.buttons.map(translateButton)
});
const activity = MessageFactory.attachment(card);
return this.sendActivity(message, activity);
});
And change button helper builder In file: lib\platforms\microsoft-teams\helpers\translate-button.js to>
module.exports = button => {
switch(button.type) {
case 'postback':
return {
"type": "Action.Submit",
"title": button.label,
"data": {
"msteams": {
"type": "messageBack",
"displayText": button.label,
"text": button.value,
"value": "{\"bfKey\": \"bfVal\", \"conflictKey\": \"from value\"}"
}
}
};
case 'url':
return {
type: 'Action.OpenUrl',
title: button.label,
value: button.url
};
}
};