Only show these results:

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.


Step 1: Create a Service Account

  1. Go to the project you created for use with Nylas.

  2. In the search bar, type Service Accounts.

  3. On the screen that opens, click CREATE SERVICE ACCOUNT.

  4. Give the account the name nylas-gmail-realtime.

    The name, nylas-gmail-realtime, is required for the integration to work.

  5. Leave Grant this service account access to project (optional) and Grant users access to this service account (optional) blank.

  6. Click Done.

Step 2: Create Pub/Sub Topic

Your Pub/Sub Topic MUST be set up in the same Google app you use to authenticate accounts with Nylas.

  1. In the search bar look for pub sub and select Pub/Sub.
  2. Click CREATE TOPIC.
  3. Enter the topic ID nylas-gmail-realtime, and leave the defaults checked. The topic ID listed is required for the integration to work.
  4. On the next page, click SHOW INFO PANEL, if it's not already open.
  5. In the panel click ADD PRINCIPAL.
  6. Add the principal
  7. Set the role to Pub/Sub Publisher.
  8. On save you should be directed to the Topics page.
  9. On the Topics page find the Subscriptions section. Click nylas-gmail-realtime-sub.
  10. Click the subscription, then click edit.
  11. Change the following:
    1. Delivery type: Push
    2. Endpoint URL:
      • for US use
      • for EU use
    3. 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

  12. When prompted, grant the roles/iam.serviceAccountTokenCreator to your service account.

    If you miss the prompt or it does not appear, follow these steps to add the role to your service account:

    1. Go to IAM & Admin > Service Accounts
    2. Copy the full service account email for the service account you created in Step 1 (should start with nylas-gmail-realtime).
    3. Select the service account (should be called nylas-gmail-realtime)
    4. Go to the Permissions tab.
    5. Make sure you are on the Principals tab at the bottom.
    6. If the service account nylas-gmail-realtime-email is 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.
    7. On the pop-up, click ADD ANOTHER ROLE.
    8. Search for service account token creator
    9. Select the role.
    10. Hit SAVE.
  13. Leave the other fields as default and click Update.
  14. 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 for Google Pub/Sub to work.

Step 3: Add the Topic Name to Your Dashboard

Before adding the Topic name, we need to enable Google Pub/Sub for your application.

  1. Go to App Settings.
  2. 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, projects/nylas-test/topics/nylas-gmail-realtime.
  3. Repeat steps one and two for every Nylas app you would like real-time Gmail message sync for.
    1. You can use the same Pub/Sub topic for all your Nylas apps.