Open in HubvThe Gmail integration allows your bot to chat with users via your Gmail address.
Once you’ve successfully configured the Gmail integration, the email address you provided will begin responding to all incoming emails as your bot. Please be aware of this behaviour before configuring the integration.
In Botpress Studio, select Explore Hub in the upper-right corner.
2
Search for the Gmail integration, then select Install Integration.
3
In the Configuration menu, select Authorize Gmail.
4
Follow the instructions to connect Botpress to your Google account.
When using basic configuration, a Botpress-managed Gmail application will be used to connect to your Gmail account. However, actions taken by the bot will be attributed to the user who authorized the connection rather than the application.For this reason, we don’t recommend using personal Gmail accounts for this integration. You should set up a service account and use that account to authorize the connection.
For more advanced use cases, you can manually configure the integration.
In Google Cloud Console, search for and navigate to the Pub/Sub section.
2
Select Subscriptions in the left sidebar.
3
Select Create subscription.
4
Enter a name for the subscription in the Subscription ID field.
5
Select the topic you created earlier from the topic dropdown.
6
Under Delivery type, select Push.
7
Enter your integration’s Botpress-provided webhook URL in the Endpoint URL field. To this URL, add ?shared_secret=, followed by the shared secret you generated earlier.
For example, if:
Your integration’s webhook URL is: https://webhook.botpress.cloud/57fcfb04-51fd-4381-909a-10e6ae53d310
Your shared secret is Ut5hzrxs7uV87mzCAKL3ztrzesWWBiNa
You would enter:https://webhook.botpress.cloud/57fcfb04-51fd-4381-909a-10e6ae53d310?shared_secret=Ut5hzrxs7uV87mzCAKL3ztrzesWWBiNain the Endpoint URL field.
8
Check the Enable authentication checkbox.
9
Select the service account email address you created earlier in the Service account field.
10
Enter the shared secret you generated earlier in the Audience field.
Although this field is marked optional in Google Console, it’s required for the integration to work properly.
11
Under Expiration period, select Never expire.
12
Under Acknowledgement deadline, enter 60 seconds.
13
Under Retry policy, select Retry after exponential backoff delay. Set the minimum backoff to 60 seconds and the maximum backoff to 600 seconds.
Replace YOUR_CLIENT_ID with your OAuth Client ID from Step 4. For example, if your OAuth client ID is abcd, the URL should end with &client_id=abcd.
3
Follow the on-screen instructions to authorize the OAuth application with your personal Gmail account.
After completing the authorization, you will be redirected to botpress.com. Don’t close this page.
4
Copy the authorization code from the URL in your browser’s address bar. The authorization code is the string that appears after code= and before &scope= in the URL.
If you update any scopes, you need to generate a new authorization code and add it to the integration’s configuration in Botpress Studio. The previous authorization code won’t have the correct scope permissions.
Once you’ve successfully configured the integration, the email address you provided will begin responding to all incoming messages as your bot. If this is your desired behaviour, no additional setup is required.You can also use the integration’s Cards to interact with your Gmail inbox. This allows you to manage threads, drafts, attachments, and other data associated with your inbox.
Botpress shall not be held responsible for any costs you may incur on the Google Cloud Platform while using the Gmail integration, should you choose to use the manual configuration mode. Ensure that you are aware of the costs associated with using the Gmail API and the Google Cloud Platform before using the manual configuration mode.
API limits
Standard Gmail API limitations apply to the Gmail integration in Botpress. These limitations include rate limits, message size restrictions, and other constraints imposed by the Gmail and Google Cloud platforms. Ensure that your bot adheres to these limitations to maintain optimal performance and reliability.More details are available in the Gmail API documentation.