Skip to content

Conversation

@mrashed-dev
Copy link
Contributor

Description

Add support for Event notifications.

Usage

To add notifications to an event:

const notificationEvent = nylas.events.build({
  ...
  notifications: [
  {
    body: 'Reminding you about our meeting.',
    minutes_before_event: 600,
    subject: 'Test Event Notification',
    type: 'email',
  },
  {
    type: 'webhook',
    minutes_before_event: 600,
    url: 'https://hooks.service.com/services/T01A03EEXDE/B01TBNH532R/HubIZu1zog4oYdFqQ8VUcuiW',
    payload: JSON.stringify({
      text: 'Your reminder goes here!',
    }),
  },
  {
    type: 'sms',
    minutes_before_event: 60,
    message: 'Test Event Notification',
  },
  ],
});

To retrieve event notification details of an event:

const event = await nylas.events.find("id");

const minutesBeforeEvent = event.notifications[0].minutesBeforeEvent
const type = event.notifications[0].type
const body = event.notifications[0].body
const url = event.notifications[0].url
const subject = event.notifications[0].subject
const payload = event.notifications[0].payload
const message = event.notifications[0].message

To update an event with a notification:

const event = await nylas.events.find("id");

event.notifications = [
  {
    body: 'Reminding you about our meeting.',
    minutes_before_event: 600,
    subject: 'Test Event Notification',
    type: 'email',
  }
];
event.save();

To delete a notification from an event:

const event = await nylas.events.find("id");

event.notifications = [];
event.save();

License

I confirm that this contribution is made under the terms of the MIT license and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #72428: Support Event Notifications.

@mrashed-dev mrashed-dev merged commit d6de83d into main Nov 5, 2021
@mrashed-dev mrashed-dev deleted the mostafarashed/sc-72428/support-event-notifications branch November 5, 2021 18:25
@mrashed-dev mrashed-dev mentioned this pull request Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants