Google Chat App - Occasionally displays an error message '... unable to process your request' when clicking a button on a card

150 Views Asked by At

In a Google Chat application developed with Apps Script, occasionally an error is displayed in the chat itself, indicating that the app "...is unable to process your request" when I click a button within a card. chat error message

Despite this error, the script is executed, and the tasks associated with it are processed. However, the return message to the chat is not delivered when the error occurs. The frequency of this error seems to increase with the processing time of the script, but even in a script with the simplest code, the error sometimes occurs.

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)
  return { "text": "This is a test Text" }

}

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

This is my appsScript.json

{
  "timeZone": "Europe/Lisbon",
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8",
  "chat": {}
}

This is an example code, but I am experiencing the same issue in a project that is becoming quite troublesome. Thank you in advance for any assistance.

In the onClickCard function, I use the Utilities.sleep() just to test the frequency of the error occurrence in longer scripts. The frequency of this error seems to increase with the processing time of the script, but even in a script with the simplest code, the error sometimes occurs. I checked the logs (Logs Explorer in Cloud Console), and no errors appear in them.

UPDATE

Sometimes Logs Explorer show anyone of this errors:

error: { code: 9 message: "An AppsScript function failed to execute. To review AppsScript error logs, see "Logging" (https://developers.google.com/apps-script/guides/logging)." }}

error: { code: 3 message: "Can't post a reply. The Chat app didn't respond or its response was invalid. See "Receive and respond to Google Chat events" (https://developers.google.com/chat/api/guides/message-formats)." }}

error: { code: 13 message: "Chat was unable to handle the bot response due to an internal error." }}

0

There are 0 best solutions below