This Choreo retrieves the next email from a user's inbox. When running this Choreo for the first time, the latest message in the inbox will be retrieved. The message's history ID will be stored in your Temboo account and used the next time you run the Choreo to retrieve only the next message that has arrived.
This Choreo can can be useful when setting up a Filter for certain emails so that a particular Gmail Label is applied to the message when it is received. Your app can then poll for new messages within the label. When using the LabelID input, history IDs will be stored along with the LabelID so that messages can be tracked per label.
The history ID that is stored in order to keep track of previously retrieved messages is only valid for about a week. If the history ID becomes invalid or expired, the Choreo will retrieve the latest message from the specified Label and reset the stored history ID. A 404 ResponseStatusCode will be returned in this case to let your application know in case any special handling is needed. If at any time, you want to clear the stored history ID to retrieve the latest message and begin storing the latest message history ID, you can run the ClearStoredHistory Choreo.
This Choreo can't retrieve messages from TRASH or SPAM.
Note: this method requires that you request one of the following scopes during the OAuth process:
https://mail.google.com/
https://www.googleapis.com/auth/gmail.modify
https://www.googleapis.com/auth/gmail.readonly
Here is an example of acceptable inputs:
ClientID: {YOUR CLIENT ID}
ClientSecret: {YOUR CLIENT SECRET}
RefreshToken: {YOUR REFRESH TOKEN}
LabelID: Label_1
The following message fields are returned as outputs: Body, From, MessageID, Snippet, Subject. In addition to these fields, the following is a sample of the JSON information returned in the Google Response:
{
"id": "1473fa6aca5e0543",
"threadId": "1473fa6aca5e0543",
"labelIds": [
"SENT",
"INBOX",
"UNREAD"
],
"snippet": "this is a test -- Aaron Jennings | Temboo | 104 Franklin Street NYC | www.temboo.com",
"historyId": "3812809",
"payload": {
"mimeType": "multipart/alternative",
"filename": "",
"headers": [
{
"name": "MIME-Version",
"value": "1.0"
},
{
"name": "Received",
"value": "by 10.152.87.42 with HTTP; Wed, 16 Jul 2014 07:49:53 -0700 (PDT)"
},
{
"name": "Date",
"value": "Wed, 16 Jul 2014 10:49:53 -0400"
},
{
"name": "Delivered-To",
"value": "aaron.jennings@temboo.com"
},
{
"name": "Message-ID",
"value": "<CAEqmo6-YNV0FrS0qyfNpxJLWMX3NnewewMX8mkA5jYxFUSFuhw@mail.gmail.com>"
},
{
"name": "Subject",
"value": "test email"
},
{
"name": "From",
"value": "Aaron Jennings <aaron.jennings@temboo.com>"
},
{
"name": "To",
"value": "Aaron Jennings <aaron.jennings@temboo.com>"
},
{
"name": "Content-Type",
"value": "multipart/alternative; boundary=001a11c258b813a03e04fe50a31b"
}
],
"body": {
"size": 0
},
"parts": [
{
"partId": "0",
"mimeType": "text/plain",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/plain; charset=UTF-8"
}
],
"body": {
"size": 91,
"data": "dGhpcyBpcyBhIHRlc3QNCg0KLS0gDQpBYXJvbiBKZW5uaW5ncyB8IFRlbWJvbyB8IDEwNCBGcmFua2xpbiBTdHJlZXQgTllDIHwgd3d3LnRlbWJvby5jb20NCg=="
}
},
{
"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": 254,
"data": "PGRpdiBkaXI9Imx0ciI-dGhpcyBpcyBhIHRlc3Q8YnIgY2xlYXI9ImFsbCI-PGRpdj48YnI-PC9kaXY-LS0gPGJyPjxkaXYgZGlyPSJsdHIiPkFhcm9uIEplbm5pbmdzIHzCoFRlbWJvbyB8IDEwNCBGcmFua2xpbiBTdHJlZXQgTllDIHzCoDxhIGhyZWY9Imh0dHA6Ly93d3cudGVtYm9vLmNvbS8iIHN0eWxlPSJjb2xvcjpyZ2IoMTcsODUsMjA0KSIgdGFyZ2V0PSJfYmxhbmsiPnd3dy50ZW1ib28uY29tPC9hPjxicj4NCjwvZGl2Pg0KPC9kaXY-DQo="
}
}
]
},
"sizeEstimate": 1058
}