Build an agent that sells products to prospects via email.
- Python 3.11 or higher
- AgentMail API key
- OpenAI API key
- Ngrok account (for receiving webhooks)
- Sign up for a free Ngrok account at ngrok.com
- Get your Ngrok auth token
- Claim your free static domain
This will create a persistent domain (your-subdomain.ngrok-free.app) that you can use to receive AgentMail webhooks.
Create a .env file with the following content:
AGENTMAIL_API_KEY=your-agentmail-api-key
OPENAI_API_KEY=your-openai-api-key
NGROK_AUTHTOKEN=your-ngrok-authtoken
INBOX_USERNAME=your-inbox-username
WEBHOOK_DOMAIN=your-webhook-domainExport enivornment variables in the .env file
export $(grep -v '^#' .env | xargs)Create an inbox
curl -X POST https://api.agentmail.to/v0/inboxes \
-H "Authorization: Bearer $AGENTMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"username\": \"$INBOX_USERNAME\",
\"display_name\": \"Email Agent\"
}"Create a webhook
curl -X POST https://api.agentmail.to/v0/webhooks \
-H "Authorization: Bearer $AGENTMAIL_API_KEY" \
-H "Content-Type: application/json" \
-d "{
\"url\": \"https://$WEBHOOK_DOMAIN/webhooks\"
}"uv venv
source .venv/bin/activate
uv pip install .Start the server
python main.pyNow send an email to your-inbox-username@agentmail.to with a product to sell and a prospect to sell to. You should provide the name and email address of the prospect.
The Sales Agent will autonomously email the prospect with a sales pitch, answer any of the prospect's questions, and report any intent signals back to you.
Note: You should restart the python script after every sales sequence as the agent stores context in local memory.