node-red-contrib-chatbot
node-red-contrib-chatbot copied to clipboard
Image + HTML caption + Buttons
I'd like to send an image with html-formated caption and actionable buttons:
Using node-red-contrib-telegrambot it is possible to achieve with the following payload:
{
"chatId": 123,
"type": "photo",
"content": "https://...jpg",
"caption": "<b>Tony Vespa</b>\n<a href=\"https://...\">link</a>",
"options": {
"parse_mode": "HTML",
"reply_markup": {
"inline_keyboard": [
[{ "text": "⭐️", "callback_data": "rate 1" }]
]
}
}
}
So I've adopted it for the RedBot:
{
"chatId": msg.originalMessage.chatId,
"type": "photo",
"content": "https://...jpg",
"caption": "<b>Tony Vespa</b>\n<a href=\"https://...\">link</a>",
"params": { "parseMode": "HTML" },
"buttons": [{
"type": "postback",
"label": "⭐️",
"value": "1",
"answer": "Rated: ⭐️",
"alert": false,
"style": ""
}]
}
Seems that type must be set to message (for html formatting), photo or inline-buttons but not combined.
I recently added the params node which allows to set the parse mode (for telegram) for every type of messages
Oh thanks! Is there a way to combine photo with buttons?
yes just chain them
receiver -> photo block -> text block -> sender block
https://github.com/guidone/node-red-contrib-chatbot/wiki/Changes-0.19.0
Chaining Conversation > Image > Buttons > Sender generates the following msg.payload:
[{
"type": "photo",
"content": buffer[78045],
"filename": "image.png",
"mimeType": "image/png",
"caption": "tony",
"chatId": "******",
"messageId": null,
"inbound": false
}, {
"type": "inline-buttons",
"name": null,
"content": null,
"chatId": "******",
"messageId": null,
"buttons": [{
"type": "postback",
"label": "⭐️",
"value": "1",
"answer": "Rated ⭐️",
"alert": false,
"style": ""
}]
}]
And only the first item is sent. I want to combine them:
"type": "photo",
"buttons": [...]
Ok, I think it's technically possible
https://core.telegram.org/bots/api#sendphoto
Telegram allows to add buttons to every type of message, the problem is that other platforms don't, so I have to come up with something that doesn't break the compatibility with other platforms and it's not too specific.
Let me think about it