Conversation API for Agents
How to create a task/conversation with an Agent
API authorization set up
When on API keys page, scroll down and you will see the Region code and your Project Id.
To generate your Relevance API key, click on "Create new secret key", with the role "Admin". Click on "Generate API key". Copy the values shown on the modal.
- Authorization token
- API key
- Region
- Project
Authorization tokens are formed by combining Project Id:API Key
.
Either directly copy the Authorization token
from the API page or use the
Project id
and API key
combination as shown in the snippet below:
Agent Id
Currently, the easiest way to access Agent Ids is from URLs.
For instance, when on the "Edit agent" page, the last piece after project id and before /edit
shows the Agent Id.
The URL is structured as
https://app.relevanceai.com/agents/{region}/{project_id}/{agent_id}/edit
Trigger an agent / Start a conversation
Agents are async and poll based so to interact with it you’ll need to trigger a job
to converse with an agent then continuously poll for updaes.
Poll the job for updates and replies from the agent.
This will poll the job every 3 minutes for updates.
Continue the conversation
To continue the conversation just call the trigger endpoint again with the conversation_id
. This conversation id can also be found in the url on the agents page https://app.relevanceai.com/agents/{region}/{project_id}/{agent_id}/{conversation_id}
.
List messages in a conversation
To list all the messages in a conversation, you can use the following code snippet. The messages will be reverse chronological order, i.e. the newest message will be the first in the list.
The messages follow this general structure:
Confirm or reject a tool run
As above, you’ll need the conversation_id
returned when you triggered the agent.
You’ll also need the action_request_id
and action
of the tool run that you want to confirm or reject.
You can find it using the api request here and it should
be the newest (first) message in your conversation.
Was this page helpful?