// This module is included in these assemblies:
// as_connecting-to-gmail.adoc

[id='add-gmail-connection-start_{context}']
= Triggering an integration when polling returns a Gmail message

To trigger execution of an integration based on email received by 
a particular Gmail account, add a Gmail connection as the start connection of
a simple integration. When the integration is running, the Gmail connection checks 
this account for emails at intervals that you control. 
When the connection finds an unread
email, it passes the email to the next step in the integration and, by default, 
marks the email as *read*.  

.Prerequisites
* You created a Gmail connection that is authorized to access the Gmail
account that you want to obtain emails from.   

.Procedure

. In the {prodname} panel on the left, click *Integrations*.
. Click *Create Integration*.
. On the *Choose a connection* page, click the Gmail connection that
you want to use to start the integration. 
. On the *Choose an action* page, select the *Receive Email* action. 
. To configure the *Receive Email* action:
.. In the *Delay* field, accept the default of 30 seconds or 
specify how often you want the integration to check for new email. 
.. Leave the *Labels* field blank to obtain any unread email. 
To obtain only certain emails, 
specify a comma-separated list of labels that are used in the Gmail 
account that the connection is accessing. By default, the integration obtains the 
unread emails that have those labels. 
.. Select *Mark as read* to ensure that the connection does not 
return the same email twice. If *Mark as read* is not selected, the
connection returns emails that are in the account's in box, whether or
not they were previously read. Or, if you specify one or more labels, then 
the integration return emails that have those labels whether or not they
were already read. 
.. In the *Max Results* field, accept the default of *5* or 
indicate the maximum number of emails that the connection 
can return for each poll. If the connection finds more than this number 
of unread emails, then it returns the most recent *Max Results* emails. 
+
When a Gmail connection returns more than one email, the integration
processes the emails as a batch. In other words, {prodname} 
executes the integration once for the batch. 
.. Click *Next* to add this Gmail connection as the start connection 
in the integration. The connection appears as the
first step in the integration flow. 
