An AI-powered composable email agent built in Python 3 that analyzes emails and generates appropriate responses using the following agent architectures:
- Parallelization with async/await
- Prompt chaining
- Python 3.7 or higher (async/await support required)
- pip3 (Python 3 package installer)
- 📧 Email Analysis
- Sentiment Analysis - Determines the emotional tone of incoming emails
- Email Summarization - Creates concise summaries of email content
- Response Decision Making - Intelligently decides if an email needs a response
- ✍️ Smart Response Generation
- Writer Style Selection - Picks appropriate tone and style for replies
- Contextual Response Generation - Creates relevant, context-aware email responses
- ⚡️ Asynchronous Processing - Parallel execution of independent tasks
- 🔌 Easy Integration - Built with the Langbase API
Let's get started with the project:
To get started with Langbase, you'll need to create a free personal account on Langbase.com and verify your email address. Done? Cool, cool!
-
Fork the following pipes on ⌘ Langbase:
-
Download and setup the project
The following command
- Downloads the example project folder from here
- Renames the folder to
example-composable-email-agent-python - Changes the directory to the project folder
- Copies the
.env.examplefile to.envin the project folder
npx degit LangbaseInc/langbase-examples/examples/email-agent-python example-composable-email-agent-python &&
cd example-composable-email-agent-python &&
cp .env.example .env- Create virtual environment:
Open a terminal and run the following commands:
# Create a virtual environment
python3 -m venv ./venv
# Activate the virtual environment
source ./venv/bin/activate- Install the required packages:
pip3 install python-dotenv aiohttp- Add the values of these environment variables to the
.envfile:
# Get your org or user API key that can be used to access everything with Langbase.
# https://langbase.com/docs/api-reference/api-keys
LANGBASE_API_KEY="USER_OR_ORG_API_KEY"- Run the email agent:
python3 agent.pyThe agent uses several components in sequence:
- Parallel Analysis: Concurrently performs sentiment analysis and email summarization using
asyncio.gather() - Decision Making: Determines if the email requires a response
- Style Selection: Chooses appropriate tone for the response
- Response Generation: Creates a contextual email response
email-agent-python/
├── .env.example # Environment variables example
├── .gitignore # Git ignore
├── agent.py # Email agent implementation
└── README.md # Project documentation