This repo contains functionality to complete two tasks:
- Backend Server: A server that will receive a request from Nylas to confirm the server endpoint is online prior to activativating a Nylas Webhook. Note the backend server must be publicly available for Nylas to call, so it needs to be hosted on a service.
The endpoint can be hosted locally, however, running a publicly available proxy/local server can be problematic as the proxy server may restrict or limit webhook creation.
- Nylas Webhook Create Script: The require code for creating a Nylas Webhook that can be run as a local script.
-
Install all the packages using
npm i
-
Add the following environment variables, consider copying the
.env.example
file and creating an.env
file:
NYLAS_CLIENT_ID=NYLAS_CLIENT_ID
NYLAS_API_KEY=NYLAS_API_KEY
NYLAS_API_URI=NYLAS_API_URI
WEBHOOK_CALLBACK_URL=WEBHOOK_CALLBACK_URL
NOTIFICATION_EMAIL=NOTIFICATION_EMAIL
# WEBHOOK_SECRET available after receiving the webhook response
WEBHOOK_SECRET=WEBHOOK_SECRET
- Host the server or add the functionality to your existing dev server for testing purposes:
npm run start
- Once the endpoint is running and publicly available on the web, run the script to create the webhook
npm run create-nylas-webhook
-
Grab the webhook secret generated in the previous step and use it to replace the empty WEBHOOK_SECRET variable
-
Create calendar events and you will the webhooks notification showing up on your application logs.