This project is a FastAPI application that receives an email, checks if it's a newsletter, and if it is, it summarizes the content and sends it to a Notion page. The application is triggered by an API call from Zapier when a new email arrives.
-
Clone the repository to your local machine.
-
Install the required Python packages using pip:
pip install -r requirements.txt
- Create a
.env
file in the root directory of the project and add your OpenAI API key, Notion API key, and Notion database ID:
OPENAI_API_KEY=your_openai_api_key
NOTION_KEY=your_notion_key
NOTION_DATABASE_ID=your_notion_database_id
- Run the FastAPI application:
uvicorn main:app --reload
To set up Zapier to trigger the API call when a new email arrives, follow these steps:
-
Create a new Zap in Zapier.
-
For the trigger, choose the Email app and the "New Inbound Email" trigger event.
-
Set up the trigger by choosing your email account.
-
For the action, choose the Webhooks app and the "POST" action event.
-
Set up the action by entering the URL of your FastAPI application and the necessary data from the email.
-
Test your Zap and turn it on.
Now, whenever a new email arrives in your inbox, Zapier will trigger an API call to your FastAPI application, which will check if the email is a newsletter, summarize it if it is, and send the summary to a Notion page.
Please replace your_openai_api_key
, your_notion_key
, and your_notion_database_id
with your actual keys. Also, adjust the setup instructions as needed based on your actual project setup.