Create Cal Event with ChatGPT 🔧

Allow ChatGPT to create a calendar Event for you via AppleScript

// Name: Create Cal Event with ChatGPT
// Description: Allow ChatGPT to create a calendar Event for you via AppleScript
// Author: Eduard Uffelmann
// Linkedin: https://www.linkedin.com/in/euffelmann/
// Twitter: @schmedu_
// Website: https://schmedu.com

import "@johnlindquist/kit";
import { startChat } from "../lib/common";
import { getCalendars, getCurrentDayOfWeek } from "../lib/functions/implementations/calendar";
import { Functions } from "../lib/functions";
import { getSetting } from "../lib/settings";

let calendars = await getCalendars();

const defaultCalendar = await getSetting("defaultCalendar");
const CALENDAR_STRING = calendars.map(cal => `- ${cal}`).join("\n")
let prompt = undefined;
await startChat({
    prompt,
    model: "gpt-4-0613", // gpt-3.5 is not reliable with times and calculation
    temperature: 1,
    systemMessage: `You are my personal assistant and you schedule my events in my calendar. I want you to create an event for me.
IMPORTANT: The current datetime is: ${new Date().toLocaleString()} in 'MM/DD/YYYY, HH:MM:SS AM/PM', it's ${await getCurrentDayOfWeek()}.
If there is no end date or duration specified, I want you to create an event for 1 hour.

The available calendars are:
${CALENDAR_STRING}

Use the first '${defaultCalendar}' calendar if no calendar is specified.

IMPORTANT: Use the 'createEvent' function to create the event.`,
    functions: [Functions.createEventFunction],
});