Repository navigation
Conversation
…iews - Add `Answer callback query` trigger to the TelegramIntegration bot. It is executed by the chat.webhook_incoming_chat_continue/_started webhooks and calls answerCallbackQuery, so Telegram stops the spinner on the clicked button. Done via bot builder only, no PHP listeners. - Same trigger calls editMessageReplyMarkup with an empty keyboard when the incoming webhook attribute `hide_buttons_on_click` is `true` (default), so visitors can't click the same buttons again, like in the website widget. - New incoming webhook attribute `disable_link_preview` (default `false`) adds `link_preview_options.is_disabled` to sendMessage. - Activator keeps administrator-edited attribute values on update and (re)creates the callback webhooks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
If button is clicked bot trigger is executed this trigger is responsible to send request back to telegram. Not additional webhooks... |
|
Thanks! I'd be glad to do it inside the bot trigger, but as far as I can see the trigger executed by the button click doesn't get
Without the id Is there a way to read the incoming payload from a trigger that I'm missing? If not, would you prefer some minimal core change instead, e.g. passing the webhook payload to the button trigger args, so the The link preview option didn't need any of this, so I sent it separately as a template-only PR: #93. |
|
Give sample how payload looks like and what attribute from it you want to reach? |
|
Sure. This is what Telegram sends to the incoming webhook when a visitor taps an inline button (ids anonymized): {
"update_id": 912345678,
"callback_query": {
"id": "4122368201564890123",
"from": { "id": 512345678, "is_bot": false, "first_name": "John", "language_code": "en" },
"message": {
"message_id": 1842,
"from": { "id": 7012345678, "is_bot": true, "first_name": "SmartDiag", "username": "smartdiag_bot" },
"chat": { "id": 512345678, "first_name": "John", "type": "private" },
"date": 1760280000,
"text": "Choose an option",
"reply_markup": {
"inline_keyboard": [[ { "text": "Yes", "callback_data": "trigger__2021__a1b2c3__98765" } ]]
}
},
"chat_instance": "-3456789012345678901",
"data": "trigger__2021__a1b2c3__98765"
}
}
Attributes I'd like to reach from that trigger:
For example, if the button trigger got the incoming payload in its args, the REST API call inside the trigger could be just: Right now the click goes Max has the same need ( |
|
You can just use this attribute which holds data of the last payload. In our scenario it's a button click :) {{args.chat.incoming_chat.payload_array.callback_query.id}} |
|
With this commit you would see. |
|
Thanks, that would be the cleanest way! But if (empty($eChat->payload)) {
$eChat->payload = json_encode($payloadAll);
}So in a normal flow (visitor writes Could the payload be refreshed on every incoming message instead, i.e. just $eChat->payload = json_encode($payloadAll);(or behind an incoming webhook option, if someone relies on the first payload)? Then the button trigger can do everything itself, no extra webhooks: and I'll update this PR to put these calls into the bot trigger as you suggested. Same for lhcmax ( |
|
I'll see tomorrow. |
|
Updated master branch to store latest payload always. |

Follow-up to #91 — done via bot builder only, as suggested there. No PHP listeners.
Problem
When a visitor taps an inline button, Telegram shows a spinner on it until the bot calls
answerCallbackQuery. Nothing answered it, so the spinner hung and visitors tapped the same button again and again, re-triggering bot flows. The buttons also stayed clickable forever, unlike in the website widget.Changes
Answer callback querytrigger in theTelegramIntegrationbot, executed by newchat.webhook_incoming_chat_continue/chat.webhook_incoming_chat_startedwebhooks (conditions: scopetelegram,callback_query.idnot empty).answerCallbackQuery— stops the spinner. Note the body uses{{args.data.callback_query.id}}without quotes: the value is JSON-encoded by the REST API action, wrapping it in quotes produces invalid JSON.editMessageReplyMarkupwith an empty keyboard — only when incoming webhook attributehide_buttons_on_clickistrue(default).disable_link_previewincoming webhook attribute (defaultfalse): when set,sendMessagegetslink_preview_options.is_disabled. If the attribute is missing nothing is added to the body.access_token, the new flags…) on update instead of resetting them to the template, and (re)creates the callback webhooks.Testing
Rendered all REST methods through
erLhcoreClassGenericBotActionRestapi::makeRequestagainst a local echo server with the attributes set totrue,falseand missing, and checked the resulting request bodies. Running in production on a Telegram bot.