API Triggers
Build your own API Triggers
API Triggers for Agents
API Triggers empower developers to programmatically activate Relevance AI agents, creating powerful automation workflows that integrate seamlessly with your existing systems and applications.
Overview
API Triggers allow you to initiate agent tasks directly through the Relevance AI API, enabling programmatic control over when and how your agents are activated. This capability is particularly valuable for developers and technical teams who want to incorporate AI agents into their applications, services, or automated workflows.
With API Triggers, you can build sophisticated systems where your agents respond to events in your custom applications, process data from proprietary systems, or execute tasks based on complex business logic that you define.
How API Triggers Work
API Triggers function by exposing endpoints in the Relevance AI API that allow you to:
- Initiate a new conversation with an agent
- Send messages to an existing conversation
- Provide context and data for the agent to process
- Receive responses and actions taken by the agent
When you make an API call to trigger an agent, the agent processes the provided information according to its configuration and instructions, then performs the appropriate actions based on its capabilities and the data received.
Setting Up API Triggers
To set up and use API Triggers for your agents:
- Navigate to your agent’s profile in the Relevance AI interface
- In the left sidebar, click on “Integrations”
- Under the “Agent profile” section, locate the “Integrations” area
- Select “API Trigger” from the available trigger options
- Configure the API Trigger settings according to your requirements
- Save your configuration
Once configured, you’ll receive the necessary API credentials and endpoint information to begin making API calls to your agent.
Using API Triggers
To use API Triggers in your applications or scripts:
Authentication
First, authenticate your API requests using your Relevance AI API key:
Triggering an Agent
To trigger an agent via the API:
Continuing a Conversation
To send additional messages to an existing conversation:
Customizing API Trigger Behavior
When configuring API Triggers, you can customize how your agent processes the incoming data:
- Input Mapping: Define how data fields in your API request map to variables the agent can use
- Context Handling: Specify how contextual information should be processed and presented to the agent
- Response Formatting: Configure how the agent’s responses should be structured in API responses
- Workflow Integration: Define specific workflows the agent should follow based on API request parameters
These customization options ensure your agent aligns perfectly with your application’s requirements and business processes.
Advanced API Trigger Features
Batch Processing
For scenarios requiring processing of multiple items, you can use batch API calls:
Webhook Callbacks
Configure your API Trigger to send webhook callbacks when the agent completes tasks:
Integration Examples
CRM Integration
Customer Support System
Best Practices for API Triggers
- Error Handling: Implement robust error handling in your API integration code
- Rate Limiting: Be mindful of API rate limits and implement appropriate throttling
- Security: Store API keys securely and use environment variables rather than hardcoding them
- Monitoring: Set up monitoring for your API trigger usage to detect issues early
- Testing: Thoroughly test your API trigger implementation in a development environment before deploying to production
Related Features
Webhook Triggers - Use webhooks to trigger your agents from third-party services that support outbound webhooks.
Integration Triggers - Connect your agents to popular third-party services using our prebuilt integration triggers.
Agent API Reference - Comprehensive documentation of the Relevance AI Agent API.