When I use the nylas events api via the node/JavaScript SDK I am able to schedule an event successfully. The problem I am experiencing is that the scheduled time is 5 hours before the ACTUAL time. For example, if the time is 14:00
(4pm) the time on my calendar will be scheduled for 09:00
(9am). I’m using convex as my backend to process event scheduling. Any help to figure this out would be really helpful.
The code I am using is below:
'use node'
import Nylas from 'nylas'
import { action, internalAction, mutation } from '../_generated/server'
import { v } from 'convex/values'
import { DateTime } from "luxon";
export const nylas = new Nylas({
apiKey: process.env.NYLAS_API_KEY!,
apiUri: process.env.NYLAS_API_URI!,
})
export const createMeetingAction = action({
args: {
name: v.string(),
email: v.string(),
grandId: v.string(),
grantEmail: v.string(),
fromTime: v.string(),
eventDate: v.string(),
meetingLength: v.number(),
title: v.string(),
description: v.string(),
provider: v.string(),
},
handler: async (ctx, args) => {
const startDateTime = DateTime.fromISO(`${args.eventDate}T${args.fromTime}:00`)
const endDateTime = startDateTime.plus({ minutes: args.meetingLength })
await nylas.events.create({
identifier: args.grandId,
requestBody: {
title: args.title,
description: args.description,
when: {
startTime: Math.floor(startDateTime.toMillis() / 1000),
endTime: Math.floor(endDateTime.toMillis() / 1000),
startTimezone: 'America/Chicago',
endTimezone: 'America/Chicago',
},
conferencing: {
autocreate: {},
provider: args.provider as any,
},
participants: [{
name: args.name,
email: args.email,
status: 'yes',
}],
},
queryParams: {
calendarId: args.grantEmail,
notifyParticipants: true,
}
})
}
})