Skip to content

Answer button clicks and hide inline buttons from the bot trigger - #94

Merged
remdex merged 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/answer-callback-from-trigger
Oct 14, 2026
Merged

remdex merged 1 commit into
LiveHelperChat:masterfrom
mysubcult:feat/answer-callback-from-trigger

Conversation

@mysubcult

Copy link
Copy Markdown
Contributor

Follow-up to #92, done the way you suggested: the bot trigger executed by the button answers the click itself, no extra webhooks. Possible now that payload_array always holds the latest update (LiveHelperChat/livehelperchat@e96276258).

Changes

Two new methods in the TelegramIntegration Rest API:

  • Answer callback query — answerCallbackQuery, stops the loading spinner on the clicked button:
    {"callback_query_id": {{args.chat.incoming_chat.payload_array.callback_query.id}}}
    
  • Hide inline buttons of the clicked message — editMessageReplyMarkup with an empty keyboard, so the visitor can't click the same buttons again (like in the website widget).

Usage: add a Rest API action with one or both methods to the trigger the button executes. check_not_empty skips the request if the last update wasn't a button click, so the same trigger works for website chats too. Documented in README.

Testing

Rendered both methods through erLhcoreClassGenericBotActionRestapi::makeRequest against a local echo server:

  • button click payload → {"callback_query_id": "4122368201564890123"} and {"chat_id": 512345678, "message_id": 1842, "reply_markup": {"inline_keyboard": []}}
  • text message payload → no request (Empty variable)

Note: main_cond from ae1f525

main_cond = message.chat.type=private is checked against the whole update, so every update without message is now rejected. Checked with isValidCondition:

update result
private text ✅
group text ❌ (intended)
button click (callback_query) ❌
edited_message ❌
message_reaction ❌

So with the current template button clicks, edits and reactions don't reach LHC at all. Conditions in main_cond are AND-ed, so I couldn't add callback_query.message.chat.type=private as an alternative — I left it untouched for you to decide how you'd like to handle it.

🤖 Generated with Claude Code

Telegram keeps a loading spinner on a clicked inline button until the bot
calls answerCallbackQuery, so visitors click the same button again and
the bot flow runs several times.

- `Answer callback query` REST method (answerCallbackQuery).
- `Hide inline buttons of the clicked message` REST method
  (editMessageReplyMarkup with an empty keyboard).

Both read the click from args.chat.incoming_chat.payload_array, which now
always holds the latest incoming update (livehelperchat e96276258), so
they are added as Rest API actions to the trigger the button executes.
No extra webhooks. check_not_empty skips them if the last update wasn't
a button click.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@remdex
remdex merged commit 1218612 into LiveHelperChat:master Oct 14, 2026
@mysubcult
mysubcult deleted the feat/answer-callback-from-trigger branch October 26, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants