Spots emails asking for a meeting, finds times your calendar is free, and replies offering them.

UsesGmailGoogle CalendarOpenAI

Reply to meeting requests with open times

Every 15 minutes, the unread mail in your inbox is read and each message is checked to see whether it is asking to arrange a meeting that still needs a time. For each one that is, your calendar is looked through weekday by weekday at the times of day you like to meet, the first few free slots are kept, and a short reply offering exactly those times is sent in the original thread.

You end up with meeting requests answered within minutes with real options from your calendar. Only slots the calendar reported as free are offered, and the times come from the calendar rather than from the AI, so nothing is proposed on top of an existing commitment. Every message dealt with is labeled 'Meeting-times-checked' and skipped next time, so nobody gets two replies. A message that could not be read, classified or answered is logged and left unlabelled for the next run, and if your calendar is full at every time you offer, the run stops rather than guessing.

Run every 15 minutes.Run every 15 minutes.
Set yourName to blank.Set yourName to blank.
Set timeZone to blank.Set timeZone to blank.
Set dailyMeetingTimes to “10:00, 14:00, 16:00”.Set dailyMeetingTimes to “10:00, 14:00, 16:00”.
Set meetingLengthMinutes to 30.Set meetingLengthMinutes to 30.
Set daysToLookAhead to 10.Set daysToLookAhead to 10.
Set timesToOffer to 3.Set timesToOffer to 3.
Set maxEmails to 15.Set maxEmails to 15.
Set handledLabel to “Meeting-times-checked”.Set handledLabel to “Meeting-times-checked”.
Set calendarId to “primary”.Set calendarId to “primary”.
GmailGmailList emails matching '-label:“@handledLabel”'. Save it as inbox.List emails matching '-label:“@handledLabel”'. Save it as inbox.
Set meetingRequests to an empty list.Set meetingRequests to an empty list.
For each email in inbox.emails:For each email in inbox.emails:
Set messageId to blank.Set messageId to blank.
Set subjectText to blank.Set subjectText to blank.
Set messageText to blank.Set messageText to blank.
If a step below fails, save the error as readErrorIf a step below fails, save the error as readError
Try
Trim email.id and save it as messageId.Trim email.id and save it as messageId.
Trim email.subject and save it as subjectText.Trim email.subject and save it as subjectText.
Trim email.body and save it as messageText.Trim email.body and save it as messageText.
On error
Show in the output: Skipped an email that is missing its id, subject or body: readError as text.Show in the output: Skipped an email that is missing its id, subject or body: readError as text.
If messageId is empty or messageText is emptyIf messageId is empty or messageText is empty
Yes
Skip to the next item.Skip to the next item.
No
No steps
Set verdict to blank.Set verdict to blank.
If a step below fails, save the error as classifyErrorIf a step below fails, save the error as classifyError
Try
OpenAIOpenAIAsk OpenAI: 'Decide whether this email is asking to arrange a meeting, call or appointment with yourName that still needs a time agreed.Ask OpenAI: 'Decide whether this email is asking to arrange a meeting, call or appointment with yourName that still needs a time agreed. Reply with exactly one word: yes or no. Reply no if a time has already been agreed, if the message only confirms, moves or cancels an existing meeting, or if it is a newsletter, receipt, notification or marketing email. Subject: subjectText messageText'. Save it as classification.
TextMake classification.response_text lowercase and save it as verdict.Make classification.response_text lowercase and save it as verdict.
On error
Show in the output: Could not tell whether “@subjectText” is a meeting request, so it was left for the next run: classifyError as text.Show in the output: Could not tell whether “@subjectText” is a meeting request, so it was left for the next run: classifyError as text.
If verdict isn't emptyIf verdict isn't empty
Yes
If verdict starts with “yes”If verdict starts with “yes”
Yes
Add a record of id, subject, and text to the end of meetingRequests and save it as meetingRequests.Add a record of id, subject, and text to the end of meetingRequests and save it as meetingRequests.
No
GmailGmailAdd label handledLabel to email messageId.Add label handledLabel to email messageId.
No
No steps
If meetingRequests isn't emptyIf meetingRequests isn't empty
Yes
Set openSlots to an empty list.Set openSlots to an empty list.
Set dayOffset to 1.Set dayOffset to 1.
While dayOffset is less than or equal to daysToLookAhead and the length of…:While dayOffset is less than or equal to daysToLookAhead and the length of…:
Get the first item of today's date in timeZone shifted by dayOffset “days” split by “T” and save it as day. Get the first item of today's date in timeZone shifted by dayOffset “days” split by “T” and save it as day.
If not day is a weekend If not day is a weekend
Yes
For each slotTime in dailyMeetingTimes split by “,”:For each slotTime in dailyMeetingTimes split by “,”:
If the length of openSlots is greater than or equal to timesToOffer If the length of openSlots is greater than or equal to timesToOffer
Yes
Stop repeating.Stop repeating.
No
No steps
Trim slotTime and save it as clockTime. Trim slotTime and save it as clockTime.
If clockTime is empty If clockTime is empty
Yes
Skip to the next item.Skip to the next item.
No
No steps
Set startsAt to “@dayT@clockTime”. Set startsAt to “@dayT@clockTime”.
Get the first item of startsAt shifted by meetingLengthMinutes “minutes” split by “.” and save it as endsAt. Get the first item of startsAt shifted by meetingLengthMinutes “minutes” split by “.” and save it as endsAt.
Google CalendarGoogle Calendar Check if the calendar is free from startsAt to endsAt. Save it as availability. Check if the calendar is free from startsAt to endsAt. Save it as availability.
If availability.isAvailable is yes If availability.isAvailable is yes
Yes
Add the weekday name of day, day at clockTime to the end of openSlots and save it as openSlots.Add the weekday name of day, day at clockTime to the end of openSlots and save it as openSlots.
No
No steps
No
No steps
Add 1 to dayOffset. Add 1 to dayOffset.
If openSlots is emptyIf openSlots is empty
Yes
Stop and report a problem: Your calendar is busy at every time in the 'dailyMeetingTimes' step for the next daysToLookAhead days, so no times were offered. Add more times or raise 'daysToLookAhead', then run it again.Stop and report a problem: Your calendar is busy at every time in the 'dailyMeetingTimes' step for the next daysToLookAhead days, so no times were offered. Add more times or raise 'daysToLookAhead', then run it again.
No
No steps
Set offeredTimes to - openSlots joined by "Set offeredTimes to - openSlots joined by “ - ”.
For each request in meetingRequests:For each request in meetingRequests:
Set replyBody to blank. Set replyBody to blank.
If a step below fails, save the error as draftError If a step below fails, save the error as draftError
Try
OpenAIOpenAIAsk OpenAI: 'Write the plain-text body of a short, friendly reply to the email below, on behalf of yourName.Ask OpenAI: 'Write the plain-text body of a short, friendly reply to the email below, on behalf of yourName. Offer these times and ask the sender to pick one, or to suggest another time if none of them work. Use only these times - do not invent, move or add any others, and do not convert them to another time zone. Times to offer (all times timeZone): offeredTimes Each meeting is meetingLengthMinutes minutes long. Write the reply body only - no subject line, no quoted text and no placeholders to fill in. Sign off as yourName. Subject: request.subject request.text'. Save it as draft.
Trim draft.response_text and save it as replyBody.Trim draft.response_text and save it as replyBody.
On error
Show in the output: Could not draft a reply to “@request.subject”, so it was left for the next run: draftError as text.Show in the output: Could not draft a reply to “@request.subject”, so it was left for the next run: draftError as text.
If replyBody isn't empty If replyBody isn't empty
Yes
GmailGmailReply to email request.Reply to email request.replyBody
GmailGmailAdd label handledLabel to email request.Add label handledLabel to email request.
No
No steps
No
No steps