Skip to content

nylas-samples/quickstart-webhook-node

Repository files navigation

How to run

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.
  1. Install all the packages using npm i

  2. 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
  1. Host the server or add the functionality to your existing dev server for testing purposes:

npm run start

  1. Once the endpoint is running and publicly available on the web, run the script to create the webhook

npm run create-nylas-webhook

  1. Grab the webhook secret generated in the previous step and use it to replace the empty WEBHOOK_SECRET variable

  2. Create calendar events and you will the webhooks notification showing up on your application logs.

About

Quickstart Webhook Guide for Node

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published