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 in your Agent
To set up and use API Triggers for your agents:
- Navigate to the Agents page and choose the specific agent you want to setup the custom API trigger for.
- In the Build tab, click on “Triggers”
- Look for the the “API trigger” section, locate the “Customer Triggers” area
- Select “API Trigger” from the available trigger options
- Configure the API Trigger settings according to your requirements
- Save your configuration
Setting up your API trigger in your Codebase
Save your API key somewhere safe
You’ll need to generate an API key (Authorization Token) to authenticate your requests. Make sure to save your API key somewhere safe. Once generated, you won’t be able to view it again. However, you can regenerate one at any time.
To find your Agent ID, you can ask your agent directly in the chat (“What is your agent ID?”). Or, you can check the URL. When your agent is open, look at the URL in your browser. The agent ID is the second long code after the region code in the URL structure: Example: https://app.relevanceai.com/agents/{region}/{project_id}/{agent_id}/edit
Request Body
Example Usage (Choose a method your prefer)
cURL
JavaScript (Fetch)
Python (requests)
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.