- Modal account: Sign up at modal.com
- Modal CLI: Install with
pip install modal
- Authentication: Run
modal setup
to authenticate
Create a Modal secret with your environment variables:
modal secret create memento-secrets \
CONVEX_URL="https://your-deployment-name.convex.cloud" \
SURGE_WEBHOOK_SECRET="your_webhook_secret_from_surge_dashboard"
modal serve src/memento/webhooks.py
modal deploy src/memento/webhooks.py
After deployment, Modal will provide you with a URL like:
https://your-workspace--memento-surge-webhooks-webhook-application-dev.modal.run
Your webhook endpoint will be:
https://your-workspace--memento-surge-webhooks-webhook-application-dev.modal.run/webhooks/surge
- Go to your Surge dashboard
- Navigate to Webhooks settings
- Add the Modal webhook URL
- Select "message.received" events
- Save the webhook configuration
- ✅ Auto-scaling: Modal handles traffic spikes automatically
- ✅ Signature validation: Secure webhook verification
- ✅ Structured logging: Detailed message information
- ✅ Health checks:
/
endpoint for monitoring - ✅ Error handling: Proper HTTP status codes
- ✅ Ready for Convex: Placeholder function for database integration
- Check logs in Modal dashboard
- Use the health check endpoint for uptime monitoring
- Monitor function calls and performance metrics
- Add Convex database integration for classification
- Add S3 storage for conversions by
ConvexMessageId
- Add OpenAI conversion
- Add Webhook Validation