The Widget Answer node answers a query sent by a Telegram widget (see the Widget node). A widget sends a query calling TelegramWidget.request(data), the query arrives on the event output of the Telegram Receiver node as a widget-query event, with the text sent by the widget in msg.payload.data. Use the Rules node with the rule Message is event … Widget query to route these events to the Widget Answer node, then connect it to the Telegram Sender node.

The Answer is a text up to 1024 bytes (usually JSON) and supports chat context templating, for example {"count": {{count}}}. It's delivered only to the widget that sent the query, as the result of its request():

TelegramWidget.request('inc').then(function(answer) {
  // answer.result is the text of the Widget Answer node, null if empty
});

The answer doesn't change the state of the widget: to update the widget for everyone, use the Widget node in Update the widget data mode.

When the answer is empty in the editor, it's taken from msg.payload.answer. In the upstream Function node

// keep the widget-query payload, add the answer
msg.payload.answer = { count: 42 }; // objects are sent as JSON
return msg;

The answer is answer and not data: msg.payload.data is the text of the query. If the upstream node replaced msg.payload, the node still finds the query in msg.originalMessage.

Available parameters for the msg.payload

Name Type Description
answer string or object The answer, up to 1024 bytes. Empty: the widget gets null
widgetQueryId string The id of the query, set by the widget-query event (also in msg.originalMessage)

Answer within 15 seconds

Telegram wants every query answered within 15 seconds and a widget can't send a new query while one is pending. If the flow doesn't answer within 12 seconds (no Widget Answer node, or an error in the flow), RedBot answers with no data and logs a warning, so the widget can send the next query. An answer that arrives later is skipped with a warning.

Every query should get an answer, even an empty one: a widget that only sends commands and gets the new state from the public data still needs a Widget Answer node, otherwise each query waits 12 seconds.