Search code examples
google-hangouts

Button payload / callback?


I want to be able to reply to a user with my bot based on a button they pressed. So far, the only property I can find for button.onClick is "openUrl", but it doesn't seem possible to assign the button a value or a payload / callback URL. Additionally, there is no "Button Tapped" event.

How can I use buttons to allow my user to interact with my bot?


Solution

  • There are multiple ways to add a button response to Hangouts Chat. The primary one seems to be via using Cards with either KeyValue, or ActionResponse.

    https://developers.google.com/hangouts/chat/how-tos/cards-onclick

    You can use:

    1. buttons.onClick.parameters.keyValue to pass unique Parameters
    2. textButton.onClick.openLink to open a link with a text button
    3. ActionResponse to update a card with a custom card when a Click event occurs.