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.
- 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:
- Select Enable Authentication and choose the service account you made in Create a Service Account.
- When prompted, grant the
roles/iam.serviceAccountTokenCreatorto your service account.
- 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.
- At the end of the URL add
?experiments=64b58f9f-661c-4dc3-9de8-2248070687dc:1. The final URL should look similar to:
https://dashboard.nylas.com/applications/app-id/settings/general?experiments=64b58f9f-661c-4dc3-9de8-2248070687dc:1. The page will refresh.
- Next, click on the Authentication tab and go to Google Auth. There is a new input added called GCP Topic Name. Input the topic created in Create a Pub/Sub Topic, for example,
- That's it, your app should be ready for real-time sync of Gmail messages.