b4b90f2d27
* perf: Removed unused queries for user event types * Added empty children array * Refactor to clean up * Fixing type issue * Removed extra call to get raw event types * Temporarily putting children back * Removing include from children * Added check for children * Put children back for testing --------- Co-authored-by: Alan <alannnc@gmail.com> |
||
---|---|---|
.. | ||
src | ||
.env.example | ||
README.md | ||
next-env.d.ts | ||
next.config.js | ||
package.json | ||
tsconfig.json |
README.md
Cal.com Email Assistant
Welcome to the first stage of Cal AI!
This app lets you chat with your calendar via email:
- Turn informal emails into bookings eg. forward "wanna meet tmrw at 2pm?"
- List and rearrange your bookings eg. "Cancel my next meeting"
- Answer basic questions about your busiest times eg. "How does my Tuesday look?"
The core logic is contained in agent/route.ts. Here, a LangChain Agent Executor is tasked with following your instructions. Given your last-known timezone, working hours, and busy times, it attempts to CRUD your bookings.
The AI agent can only choose from a set of tools, without ever seeing your API key.
Emails are cleaned and routed in receive/route.ts using MailParser.
Incoming emails are routed by email address. Addresses are verified by DKIM record, making it hard to spoof them.
Getting Started
Development
If you haven't yet, please run the root setup steps.
Before running the app, please see env.mjs for all required environment variables. You'll need:
- An OpenAI API key with access to GPT-4
- A SendGrid API key
- A default sender email (for example,
ai@cal.dev
) - The Cal AI's app ID and URL (see add.ts)
To stand up the API and AI apps simultaneously, simply run yarn dev:ai
.
Email Router
To expose the AI app, run ngrok http 3000
(or the AI app's port number) in a new terminal. You may need to install nGrok.
To forward incoming emails to the Node.js server, one option is to use SendGrid's Inbound Parse Webhook.
- Sign up for an account
- Go to Settings > Inbound Parse > Add Host & URL.
- For subdomain, use
<sub>.<domain>.com
for now, wheresub
can be any subdomain butdomain.com
will need to be verified via MX records in your environment variables, eg. on Vercel. - Use the nGrok URL from above as the Destination URL.
- Activate "POST the raw, full MIME message".
- Send an email to
<anyone>@ai.example.com
. You should see a ping on the nGrok listener and Node.js server. - Adjust the logic in receive/route.ts, save to hot-reload, and send another email to test the behaviour.
Please feel free to improve any part of this architecture.