Skip to content

Forward an email and use AI to turn it into a calendar event.

License

Notifications You must be signed in to change notification settings

moeadham/fwd2cal

Repository files navigation

fwd2cal

forward an email => get calendar event

That's it. No buttons, no clicking - just forward an email, and a calendar event gets added to your Google Calendar.

fwd2cal uses an LLM to parse the thread, generate a JSON of the event details, and then adds the event to your google calendar.

fwd2cal.com - running in production, free until it gets annoying/expensive to run.

fwd2cal.create.mp4

You can self host - it runs on firebase functions.

Features:

  • Signup with an email: just email [email protected] and you'll be sent a google auth link.
  • Send from multiple email addresses: send add [email protected] to [email protected], and then you can add events to your google calendar from another email address
  • Completely private: No logging, or storage of any emails. All that is stored are your email addresses.
  • That's it. The goal is to just do one thing correctly and stay out of the way of the user.

Self hosting setup

You will need:

  1. a firebase project
  2. an openAI API key with gpt4 access
  3. a sendgrid account setup with a domain to receive emails
firebase functions:config:set environment.name="production"
firebase functions:config:set environment.openai_api_key="sk-YOUR_API_KEY"
firebase functions:config:set environment.sendgrid_api_key="YOUR_API_KEY"
firebase functions:config:set environment.sendgrid_endpoint="very_hard_to_guess_endpoint"
firebase functions:config:set environment.sentry_dsn="your sentry dsn"
firebase functions:config:set environment.ga_secret="GA measurement protocol 4 api key"
firebase functions:config:set environment.ga_measurement="GA measurement ID"

Make sure you then set the secret URL as your parse URL in sendgrid.

Local setup

For local, edit .runtimeconfig.json

{
  "environment": {
    "name": "local",
    "openai_api_key": "sk-YOUR_API_KEY",
    "sendgrid_api_key": "your-sendgrid-api-key",
  }
}

Also - you're probably going to want to save your credentials from https://console.cloud.google.com/apis/credentials to: functions/auth/google-auth-credentials.json.

You want to make sure your redirect_uris are setup correctly. It is a list, [0] should be the default from firebase, [1] should be http://localhost:5001/yourappname/your-region/oauthCallback, and [2] should be the prod url.

Testing

export TESTER_PRIMARY_GOOGLE_ACCT="[email protected]"
export TESTER_SECONDARY_EMAIL_ACCT="[email protected]"
cd functions
npm test

Make sure you authorize your google account in 30 seconds after starting the test so the tests can run.

To test pubsub cron jobs:

firebase functions:shell
refreshTokensScheduled()

If you know how to make a test script properly send a pubsub message on the firebase emulator, a PR would be appreciated.

Contributing

All contributions are welcome. I will do by best to keep main stable.

Where you can help:

  • functions/util/prompts.js - Prompt engineers can help here, if you notice fwd2cal fail to add your event correctly, think of adding an example to the prompt that teaches gpt4
  • Timezones - I find the current prompt is bad at understanding timezones; likely worth adding another prompt only to detect the timezone.
  • Multiple calendars: right now all events are added to the default calendar - but GPT4 can likely understand the context of all the users calendar and select an appropriate one.
  • Get rid of all the hard coded references to fwd2cal.com so it can be self hosted easier.
  • Find a way to add a test for the oAuth refresh tokens. I didn't bother
  • Upgrade to firebase functions v2

Author

This was written by @moeadham to get familiar with firebase and webstudio - training for a much larger project I'm working on.

About

Forward an email and use AI to turn it into a calendar event.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published