Google Chat App - Script repeats twice on android devices

32 Views Asked by At

In a Google Chat application developed with Apps Script, when using the standalone chat app on an Android device, if the chat throws the error '...is unable to process your request' upon clicking a button within a card (due to script execution taking more than 5 seconds), the script associated with the action of the button repeats twice.

I provide an example of my code and the onMessage functions (which create the card with a button) and onClickCard.

function onCardClick(event) {
  Utilities.sleep(5000)
  console.log("Clicked")
}

function onMessage(event) {
  return {
    "cardsV2": [
      {
        "cardId": "TestPoker",
        "card": {
          "sections": [
            {
              "widgets": [
                {
                  "buttonList": {
                    "buttons": [
                      {
                        "text": "Test Button",
                        "onClick": {
                          "action": {
                            "function": "test"
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          ]
        }
      }
    ]
  }
}

With this simple code, where I use the sleep method to emulate a longer script, the app throws the message '...is unable to process your request', and the script executes twice in android standalone chat app. In the logging, the onCardClick function executes 2 times, and each time, the script logs the message 'Clicked' to the console. In a regular browser, despite throws the message '...is unable to process your request', the script only execute one time. Using the chat app on the mobile browser also doesn't repeat twice.

0

There are 0 best solutions below