Google Pub/Sub for Message Sync
If you want to sync data between Gmail and Nylas even faster, you can use Google Pub/Sub for real-time syncing of Gmail messages. This guide will take you through the set up process.
- An existing Google app connected to your Nylas application.
Go to the project you created for use with Nylas.
In the search bar, type Service Accounts.
On the screen that opens, click CREATE SERVICE ACCOUNT.
Give the account the name
nylas-gmail-realtime, is required for the integration to work.
Leave Grant this service account access to project (optional) and Grant users access to this service account (optional) blank.
Your Pub/Sub Topic MUST be set up in the same Google app you use to authenticate accounts with Nylas.
- In the search bar look for pub sub and select Pub/Sub.
- Click CREATE TOPIC.
- Enter the topic ID
nylas-gmail-realtime, and leave the defaults checked. The topic ID listed is required for the integration to work.
- On the next page, click SHOW INFO PANEL, if it's not already open.
- In the panel click ADD PRINCIPAL.
- Add the principal
- Set the role to Pub/Sub Publisher.
- On save you should be directed to the Topics page.
- On the Topics page find the Subscriptions section. Click
- Click the subscription, then click edit.
- Change the following:
- Delivery type: Push
- Endpoint URL:
- for US use
- for EU use
- for US use
- Select Enable Authentication and choose the service account you made in Create a Service Account.
If you are setting up multiple regions in a single GCP application, create a subscription for each region
- When prompted, grant the
roles/iam.serviceAccountTokenCreatorto your service account.
If you miss the prompt or it does not appear, follow these steps to add the role to your service account:
- Go to IAM & Admin > Service Accounts
- Copy the full service account email for the service account you created in Step 1 (should start with
- Select the service account (should be called
- Go to the Permissions tab.
- Make sure you are on the Principals tab at the bottom.
- If the service account
nylas-gmail-realtime-emailis not listed under principals, click Grant Access and paste the email into the New Principles field.
- If it is listed, click the edit icon next to that principal.
- On the pop-up, click ADD ANOTHER ROLE.
- Search for
service account token creator
- Select the role.
- Hit SAVE.
- Leave the other fields as default and click Update.
- After saving, it will take you back to the Subscription page. Copy the Topic Name for the next step.
The topic name must be
nylas-gmail-realtime. The principal must use the email
email@example.com for Google Pub/Sub to work.
Before adding the Topic name, we need to enable Google Pub/Sub for your application.
- Go to App Settings.
- Click on the Authentication tab and go to Google Auth. There is a input called GCP Topic Name. Input the topic created in Create a Pub/Sub Topic, for example,
- Repeat steps one and two for every Nylas app you would like real-time Gmail message sync for.
- You can use the same Pub/Sub topic for all your Nylas apps.