Send a custom instruction

Updated

Sends a custom text instruction to a specified Conversational AI agent instance.

https://api.agora.io/api/conversational-ai-agent/v2/projects/{appid}/agents/{agentId}/think

Use this endpoint to send a custom text instruction to the specified Conversational AI agent instance. The instruction is injected into the current conversation pipeline as user input, and the agent processes and responds to it following the standard user input logic.

Use this endpoint for the following scenarios:

  • Implicit instruction injection: Inject hidden context or directives into the conversation.
  • Client-side event triggering: Notify the agent of client-side events, such as a user clicking a button.
  • Voice and text collaboration: Combine text instructions with voice input for richer interaction.

Path Parameters

appid
*
string

The App ID of the project.

agentId
*
string

The agent instance ID you obtained after successfully calling join to Start a conversational AI agent.

Request Body

application/json

text
required
string

The custom instruction text to inject into the current conversation pipeline. The system processes this as user input.

on_listening_action
optional
string

The action to take when the agent is in a listening state:

  • inject: Inject the custom text instruction into the current turn without interrupting it.
  • interrupt: Immediately interrupt the current flow and initiate a new round of dialogue.
  • ignore: Ignore the request.
Default
interrupt
Allowed
inject | interrupt | ignore
on_thinking_action
optional
string

The action to take when the agent is in a thinking state:

  • interrupt: Interrupt the current state and start a new conversation turn.
  • ignore: Ignore the request.
Default
interrupt
Allowed
interrupt | ignore
on_speaking_action
optional
string

The action to take when the agent is in a speaking state:

  • interrupt: Interrupt the current state and start a new conversation turn.
  • ignore: Ignore the request.
Default
ignore
Allowed
interrupt | ignore
interruptable
optional
boolean

Whether user speech can interrupt the injected instruction:

  • true: User speech can interrupt the instruction.
  • false: User speech cannot interrupt the instruction.
Default
true
metadata
optional
object

Custom metadata in key-value pair format. Use this field to pass additional business information such as identifiers or model references.

Response

  • If the returned status code is 200, the request was successful. The response body contains the result of the request.

  • If the returned status code is not 200, the request failed. The response body includes the detail and reason for failure. Refer to status codes to understand the possible reasons for failure.

Response Body

application/json

application/json

Response schema

200
application/json

The request was successful. The response body contains the result of the request.

agent_id
optional
string

Unique identifier of the agent instance.

channel
optional
string

The name of the RTC channel where the agent is located.

start_ts
optional
integer

Timestamp indicating when the agent was created.

default
application/json

The request failed. The response body includes the error details.

detail
optional
string

Detailed error information.

reason
optional
string

The reason for the failure.

Authorization

This endpoint requires authentication.

tokenAuthbasicAuth

Request examples

curl --request POST \
    --url https://api.agora.io/api/conversational-ai-agent/v2/projects/:appid/agents/:agentId/think \
    --header 'Authorization: Basic <credentials>' \
    --header 'Content-Type: application/json' \
    --data '{
      "text": "The user just clicked the purchase button.",
      "on_listening_action": "interrupt",
      "on_thinking_action": "interrupt",
      "on_speaking_action": "ignore",
      "interruptable": true,
      "metadata": {
        "publisher": "user123",
        "model": "deepseek-r1"
      }
    }'

Response example

{  "agent_id": "1NT29XxxxxxxxxELWEHC8OS",  "channel": "test_channel",  "start_ts": 1744877089}