Agent Webhooks
Launch agents in response to emails
Agent webhooks are designed to allow you to launch an agent in response to a message from a platform like email, slack, etc.
Not to be confused with webhooks, which allows you to receive a notification when an approval or human contact
is completed, Agent webhooks are specifically designed for kicking off new tasks and workflows. They use the same webhook
console in the HumanLayer dashboard, with an event type of v1beta2.agent_email.received
.
Agent webhooks are currently in beta. If you’d like to help us test and improve the feature, please reach out to us at contact@humanlayer.dev
Breaking Change 01/2025: Agent webhooks are transitioning to a new format.
Please use the v1beta2.agent_email.received
event type to configure where
email webhooks are sent. The email address configuration functionality remains
unchanged.
Use cases
Agent webhooks are useful for:
- Forwarding an email to an agent to handle
- Launching an agent workflow in response to a message in Slack
You can see examples of using agent webhooks in:
- Mailcrew - an open source agent that uses HumanLayer to receive and respond to inbound emails
- FastAPI Email Example - a complete example of handling inbound emails with FastAPI
Overview
To get started with agent webhooks, you’ll need to:
- Implement an AI Agent in your language and/or framework of choice, and create an API endpoint that can launch the agent
- Create a publicly reachable URL that can receive webhooks from HumanLayer (we recommend ngrok to catch webhooks while you’re developing locally)
- Create a new agent webhook in the HumanLayer dashboard
- Configure your webhook endpoint to receive events with the
v1beta2.agent_email.received
event type in the Response Webhooks section of the HumanLayer dashboard - Test the webhook by sending an email to the webhook email address
Email Payload
The webhook payload models are defined in models_agent_webhook.py.
For email webhooks, the payload will have the following structure:
a JSON example might look like
State Preservation
When making function calls or human contacts, you can include a state object that will be preserved and returned in webhooks. This allows your application to be stateless while maintaining context across the request lifecycle.
Example: