Triggered Responses
Triggered responses allow your agent to send messages outside the normal request/reply cycle. This enables proactive, human-like interactions where the agent can reach out to customers without waiting for them to speak first, or to follow-up during long-running operations, or when the customer is idle.
Why Triggered Responses?​
We've all experienced situations where a customer service representative says "Let me check that for you" while looking something up, or a store employee approaches us asking "Is there anything I can help you with?" without us initiating the conversation.
Triggered responses let your AI agents replicate these natural interactions by sending messages whenever your application decides it's appropriate, not just in response to customer input.
Triggering Agent Responses​
To trigger an agent response, create a message event with source: "ai_agent" via the client SDK or REST API:
- Python
- TypeScript
- cURL
from parlant.client import AsyncParlantClient
client = AsyncParlantClient(base_url="http://localhost:8800")
# Trigger the agent to generate a response
await client.sessions.create_event(
session_id=SESSION_ID,
kind="message",
source="ai_agent",
)
import { ParlantClient } from "parlant-client";
const client = new ParlantClient({ baseUrl: "http://localhost:8800" });
// Trigger the agent to generate a response
await client.sessions.createEvent(SESSION_ID, {
kind: "message",
source: "ai_agent",
});
curl -X POST "http://localhost:8800/sessions/${SESSION_ID}/events" \
-H "Content-Type: application/json" \
-d '{
"kind": "message",
"source": "ai_agent"
}'
When you trigger an agent response this way, the agent will generate a contextually appropriate message based on the current conversation state and active guidelines.
Guided Responses​
You can guide what the agent says by providing guidelines with the trigger. This is useful when you want the agent to communicate something specific.
- Python
- cURL
await client.sessions.create_event(
session_id=SESSION_ID,
kind="message",
source="ai_agent",
guidelines=[
{
"action": "Ask if the customer needs any more help",
"rationale": "follow_up",
}
],
)
curl -X POST "http://localhost:8800/sessions/${SESSION_ID}/events" \
-H "Content-Type: application/json" \
-d '{
"kind": "message",
"source": "ai_agent",
"guidelines": [
{
"action": "Ask if the customer needs any more help",
"rationale": "follow_up"
}
]
}'
Rationale Types​
The rationale field helps the agent understand the context for the message:
| Rationale | Use Case |
|---|---|
follow_up | Proactive check-ins, reminders, or continuing a conversation after a pause |
buy_time | Acknowledgment messages while a longer operation is in progress |
unspecified | General-purpose triggered messages |