This Choreo allows you to access a read-only Gmail feed that contains a list of unread emails. The documentation for this Gmail feed can be found here.
This Choreo has two optional inputs that can be helpful when parsing this feed. Here are a few things to remember:
- An XPath query input can be used to parse specific fields in the feed.
- When the Mode input is set to select, the XPath query will return the first match.
- When the Mode input is set to recursive, the XPath query will be applied within a loop, and the Choreo will format the result as a list in JSON format.
Here's an example of a set of inputs that would return the basic feed from Gmail:
ClientID: {YOUR CLIENT ID}
ClientSecret: {YOUR CLIENT SECRET}
RefreshToken: {YOUR REFRESH TOKEN}
ResponseFormat: XML
The XML returned with the above set of inputs would look something like this:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://purl.org/atom/ns#" version="0.3">
<title>Gmail - Label 'inbox' for aarontemboodev@gmail.com</title>
<tagline>New messages in your 'inbox' label</tagline>
<fullcount>0</fullcount>
<link rel="alternate" href="http://mail.google.com/mail" type="text/html"/>
<modified>2013-09-16T19:36:17Z</modified>
<entry>
<title>message 2</title>
<summary>Hey, this is test # 2</summary>
<link rel="alternate" href="http://mail.google.com/mail?account_id=aarontemboodev@gmail.com&message_id=1412838d4b5d7eda&view=conv&extsrc=atom" type="text/html"/>
<modified>2013-09-16T19:21:55Z</modified>
<issued>2013-09-16T19:21:55Z</issued>
<id>tag:gmail.google.com,2004:1446363073217396442</id>
<author>
<name>aaron.jennings@temb.</name>
<email>aaron.jennings@temboo.com</email>
</author>
</entry>
<entry>
<title>message 1</title>
<summary>Hey, this is test # 1</summary>
<link rel="alternate" href="http://mail.google.com/mail?account_id=aarontemboodev@gmail.com&message_id=14128389bd9721bb&view=conv&extsrc=atom" type="text/html"/>
<modified>2013-09-16T19:21:40Z</modified>
<issued>2013-09-16T19:21:40Z</issued>
<id>tag:gmail.google.com,2004:1446363057953907131</id>
<author>
<name>aaron.jennings@temb.</name>
<email>aaron.jennings@temboo.com</email>
</author>
</entry>
</feed>
To return JSON instead of XML, you can set the ResponseFormat to "json", and the Response will look like this:
{
"@xmlns": "http://purl.org/atom/ns#",
"@version": "0.3",
"title": "Gmail - Inbox for aarontemboodev@gmail.com",
"tagline": "New messages in your Gmail Inbox",
"fullcount": "2",
"link": {
"@rel": "alternate",
"@href": "http://mail.google.com/mail"
},
"modified": "2013-09-16T22:20:32Z",
"entry": [
{
"title": "message 2",
"summary": "Hey, this is test # 2",
"link": {
"@rel": "alternate",
"@href": "http://mail.google.com/mail?account_id=aarontemboodev@gmail.com&message_id=1412838d4b5d7eda&view=conv&extsrc=atom"
},
"modified": "2013-09-16T19:21:55Z",
"issued": "2013-09-16T19:21:55Z",
"id": "tag:gmail.google.com,2004:1446363073217396442",
"author": {
"name": "aaron.jennings@temb.",
"email": "aaron.jennings@temboo.com"
}
},
{
"title": "message 1",
"summary": "Hey, this is test # 1",
"link": {
"@rel": "alternate",
"@href": "http://mail.google.com/mail?account_id=aarontemboodev@gmail.com&message_id=14128389bd9721bb&view=conv&extsrc=atom"
},
"modified": "2013-09-16T19:21:40Z",
"issued": "2013-09-16T19:21:40Z",
"id": "tag:gmail.google.com,2004:1446363057953907131",
"author": {
"name": "aaron.jennings@temb.",
"email": "aaron.jennings@temboo.com"
}
}
]
}
If for example, you wanted to extract the first instance of the summary field, you could provide the following inputs:
ClientID: {YOUR CLIENT ID}
ClientSecret: {YOUR CLIENT SECRET}
RefreshToken: {YOUR REFRESH TOKEN}
Mode: select
XPath: /feed/entry/summary
With the above inputs, the Response would be:
Hey, this is test # 2
But let's say that you want to return a list of all of the values in each of the summary nodes. In this case, you would provide inputs like this:
Mode: recursive
XPath: /feed/entry/summary
ResponseFormat: JSON
The configuration above would return a result that looks like this:
[
"Hey, this is test # 2",
"Hey, this is test # 1"
]