How to get formInputs in the commonEventObject from gmail add-on in python alternative runtime?

I am trying to develop a gmail add-on, and have successfully used my deployment resource to send requests to my http endpoint. When I click a button in my add-on, I log the contents of the request from my flask application to the google cloud console. In request.data, I am able to see a commonEventObject. It looks like this:

"commonEventObject": {"hostApp": "GMAIL", "platform": "WEB"}

However, what I am looking for in the commonEventObject is “formInputs”, as described in the JSON schema: https://developers.google.com/workspace/add-ons/guides/alternate-runtimes#common-event

Here is what the JSON for my button which triggers the request looks like:

{
                    "buttonList": {
                        "buttons": [
                            {
                                "text": "Default text button",
                                "onClick": {
                                    "action": {
                                        "function": "https://myendpointaddress.run.app/click_action"
                                    }
                                }
                            }
                        ]
                    }
                }

The logs that I am viewing from google cloud originate from python like this:

@app.route('/click_action', methods=['POST'])
def click_action():
  print(request.data)

Here is my deployment resource:

{
  "oauthScopes": ["https://www.googleapis.com/auth/gmail.addons.execute", "https://www.googleapis.com/auth/gmail.readonly"],
  "addOns": {
    "common": {
      "name": "My logging add on",
      "logoUrl": "https://fonts.gstatic.com/s/i/googlematerialicons/markunread_mailbox/v6/black-24dp/1x/gm_markunread_mailbox_black_24dp.png",
      "homepageTrigger": {
        "runFunction": "https://myendpointaddress.run.app/handle_post"
      }
    },
    "gmail": {
      "contextualTriggers": [{
        "unconditional": {
        },
        "onTriggerFunction": "https://myendpointaddress.run.app/handle_post"
      }]
    },
    "drive": {
    },
    "calendar": {
    }
  }
}

Any and all advice is appreciated!

It turns out the description of formInput, found in the schema here https://developers.google.com/workspace/add-ons/guides/alternate-runtimes#common-event is very literal. It shows the values of the widgets in the card. If you don’t set any “value” fields in your widgets, it has no data to send, and is seemingly omitted from the commonEventObject.

Leave a Comment