Gmail Plugin Not Handling Different Responses?

Hi!

I’ve been spinning on this all day… maybe someone has the answer.

Gmail appears to deliver two different styles of payloads when you initiate a get.message request. If a message has been HTML-encoded, it returns this payload with two different body tags (data removed for privacy):

{
“id”: “15eb328a09b4812e”,
“threadId”: “15eb328a09b4812e”,
“labelIds”: [
“IMPORTANT”,
“CATEGORY_UPDATES”
],
“snippet”: “SNIPPET GOES HERE”,
“historyId”: “693444”,
“internalDate”: “1506244335000”,
“payload”: {
“partId”: “”,
“mimeType”: “multipart/alternative”,
“filename”: “”,
“headers”: [
{
“name”: “Delivered-To”,
“value”: "email@email.com"
},
{
“name”: “Received”,
“value”: “by 10.74.137.140 with SMTP id r12csp1484055ooh; Sun, 24 Sep 2017 02:12:18 -0700 (PDT)”
},
{
“name”: “X-Google-Smtp-Source”,
“value”: “SOURCE CODE”
},
{
“name”: “X-Received”,
“value”: “by 10.55.181.134 with SMTP id e128mr6143668qkf.62.1506244337977; Sun, 24 Sep 2017 02:12:17 -0700 (PDT)”
},
{
“name”: “ARC-Seal”,
“value”: "
},
{
“name”: “ARC-Message-Signature”,
“value”: "
},
{
“name”: “ARC-Authentication-Results”,
“value”: “”
},
{
“name”: “Return-Path”,
“value”: “”
},
{
“name”: “Received”,
“value”: “”
},
{
“name”: “Received-SPF”,
“value”: “”
},
{
“name”: “Authentication-Results”,
“value”: “”
},
{
“name”: “Received”,
“value”: “”
},
{
“name”: “Received”,
“value”: “”
},
{
“name”: “DKIM-Signature”,
“value”: “”
},
{
“name”: “Received”,
“value”: “”
},
{
“name”: “Date”,
“value”: “Sun, 24 Sep 2017 09:12:15 +0000”
},
{
“name”: “From”,
“value”: “”
},
{
“name”: “To”,
“value”: “”
},
{
“name”: “Message-ID”,
“value”: “”
},
{
“name”: “Subject”,
“value”: “”
},
{
“name”: “Mime-Version”,
“value”: “1.0”
},
{
“name”: “Content-Type”,
“value”: “multipart/alternative; boundary=”–==_mimepart_59c776eff1bbf_7fa9a436997c339658eb"; charset=UTF-8"
},
{
“name”: “Content-Transfer-Encoding”,
“value”: “7bit”
},
{
“name”: “X-Metadata-send-date”,
“value”: “20170923”
},
{
“name”: “X-Metadata-merchant-token”,
“value”: “AYTT6MDNPWH13”
},
{
“name”: “X-Metadata-email-type”,
“value”: “revamped-daily-sales-summary”
},
{
“name”: “butter-method-name”,
“value”: “day_in_review”
},
{
“name”: “X-Butter-Ignore-Undeliverable”,
“value”: “”
},
{
“name”: “X-Delivery-Token”,
“value”: “”
},
{
“name”: “List-Unsubscribe”,
“value”: “”
},
{
“name”: “X-Reply-To-Service”,
“value”: “”
}
],
“body”: {
“size”: 0
},
“parts”: [
{
“partId”: “0”,
“mimeType”: “text/plain”,
“filename”: “”,
“headers”: [
{
“name”: “Content-Type”,
“value”: “text/plain; charset=UTF-8”
},
{
“name”: “Content-Transfer-Encoding”,
“value”: “quoted-printable”
}
],
“body”: {
“size”: 1188,
“data”: “BODY PLAIN TEXT BASE 64”
}
},
{
“partId”: “1”,
“mimeType”: “text/html”,
“filename”: “”,
“headers”: [
{
“name”: “Content-Type”,
“value”: “text/html; charset=UTF-8”
},
{
“name”: “Content-Transfer-Encoding”,
“value”: “quoted-printable”
}
],
“body”: {
“size”: 57820,
“data”: “BODY HTML BASE 64”
}
}
]
},
“sizeEstimate”: 68203
}

But… if the message isn’t HTML encoded, gmail returns this payload:

{
“id”: “15eb692ea6cf97a0”,
“threadId”: “15eb692ea6cf97a0”,
“labelIds”: [
“SENT”
],
“snippet”: “”,
“historyId”: “693757”,
“internalDate”: “1506301635000”,
“payload”: {
“partId”: “”,
“mimeType”: “text/html”,
“filename”: “”,
“headers”: [
{
“name”: “Received”,
“value”: “”
},
{
“name”: “MIME-Version”,
“value”: “1.0”
},
{
“name”: “Content-Type”,
“value”: "text/html; charset=“utf-8"”
},
{
“name”: “Content-Transfer-Encoding”,
“value”: “7bit”
},
{
“name”: “Subject”,
“value”: “”
},
{
“name”: “From”,
“value”: “”
},
{
“name”: “To”,
“value”: “”
},
{
“name”: “Cc”,
“value”: “”
},
{
“name”: “Date”,
“value”: “Sun, 24 Sep 2017 18:07:15 -0700”
},
{
“name”: “Message-Id”,
“value”: “”
}
],
“body”: {
“size”: 426,
“data”: “PLAIN TEXT BASE 64”
}
},
“sizeEstimate”: 904
}

So the problem is that the options in the selector for the plugin assume that you are always getting payload parts. But clearly, if the message isn’t HTML-encoded, you only get the header info and one “body” part. The plugin doesn’t seem to be able to grab that body part. I’m stuck on what to do.

I realize I can make two different workflow hooks, one for each type and separate on conditions of item>1… but the problem is that with the payload that doesn’t have the body parts I can’t get the body with the plugin.

Thoughts?