The Widget node sends an interactive widget to a Telegram chat: a small HTML document, with its CSS and JavaScript, that Telegram renders inside the chat bubble. A widget can show some state (a score, a counter, an order status) and, with the TelegramWidget.request() JavaScript method, send data to the chatbot. To learn more about Telegram widgets read here.
In production Telegram allows widgets only in the private chat with the bot. Groups, forwards and inline mode work only on the Telegram test server, and widgets can never be posted in channels.
The node has three modes.
TelegramWidget.request(){{widgetId}}A new Widget node starts with an example, with queries enabled: a card styled with Tailwind CSS classes (inlined), in light and dark theme, with a button that sends {"action":"hello","value":42} to the chatbot and shows the answer.
The HTML is not templated, a widget's JavaScript can contain {{. The dynamic content goes in the public and chat data, which support chat context templating, for example {"count": {{count}}}.
When a widget is sent, the id of its message is stored in the chat context as {{widgetMessageId}} (also in {{outboundMessageId}}).
Sends again a shared widget by its Widget ID (for example {{widgetId}}), with its own Chat data and Caption. The code, the size and the public data are the ones of the shared widget.
Changes the state of a widget without sending a new message (the message is not marked as edited). The code of a widget can't be changed.
{{widgetMessageId}})When the message id or the widget id are empty, they are taken from msg.payload or, in reply to a widget-query event, from the widget that sent the query (even if an upstream Function node replaced the msg.payload).