Live sessions
See the calls your organization has in progress right now, and change an agent's prompt or variables mid-call without touching the agent.
A live session is a call that is happening right now. It exists from the moment a call connects until it ends, and then it is gone. The live-sessions API lets you list those calls and adjust one of them while it runs.
Live sessions are not a way to place a call. You start a call with a phone call or a web call, and you read finished calls through the calls API. Use live sessions for two jobs:
- Check concurrency. List what is in progress before you place another call.
- Steer a running call. Feed the agent something it learned halfway through, such as the caller's plan, or replace its instructions for the rest of the conversation.
List the calls in progress
curl https://api.dialgem.com/v1/agent/sessions \
-H "X-API-Key: $DIALGEM_API_KEY"The response holds sessions and a count. Each session carries:
| Field | Meaning |
|---|---|
session_id | The id of the live session. |
agent_id | The agent on the call. |
status | active or ended. |
started_at | When the call began. |
conversation | The turns so far. |
transcript | The transcript so far, as text. |
You only ever see your own organization's calls.
Change a call while it runs
Send a PATCH with a new system_prompt, new dynamic_variables, or both. Use either the session_id from the list or the call's own call_id.
curl -X PATCH https://api.dialgem.com/v1/agent/sessions/CALL_ID \
-H "X-API-Key: $DIALGEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"dynamic_variables": { "plan": "pro", "customer_name": "Maria Lopez" }
}'A successful response looks like this:
{
"session_id": "CALL_ID",
"status": "active",
"updated": ["dynamic_variables"],
"applies_from": "next_turn"
}What the change does
- It applies from the agent's next turn. A sentence already being spoken finishes as it was.
- It affects this call only. The agent, its saved versions and every other call are untouched. The change disappears when the call ends.
system_promptreplaces the prompt for the rest of the call. It must be 1 to 100,000 characters.dynamic_variablesare merged over the call's existing variables. Values must be text, numbers or booleans, and the whole object must stay under 16,000 characters. A{{plan}}in the prompt reads the new value on the next turn. See Variables.- Send at least one of the two fields. An empty request is rejected.
A flow agent takes its instructions from its nodes, so its prompt cannot be replaced mid-call. You can still change its variables.
Errors
| Status | Code | Cause |
|---|---|---|
| 404 | not found | The call is not live, or belongs to another organization. |
| 409 | session_ended | The call has already finished. |
| 422 | flow_agent_prompt | You sent system_prompt for a flow agent. |
| 422 | invalid_request | Neither field was sent, or a variable has an unsupported type or the object is too large. |
| 504 | instance_timeout | The server holding the call did not answer in time. |
The update is not retried automatically by the SDKs, so a failure reaches your code. Only retry it if repeating the change is safe for you.
The routes are available to keys with the calls scope. Every field is listed under Live sessions in the API reference.