Pass data to the agent
Fill the agent's prompt with the visitor's details, tag the call with your own ids, pick an agent version and read the result.
Everything on this page is set by your server when it creates the call. The visitor's page cannot read or change it, so you can trust it.
Create-call fields
| Field | Required | What it does |
|---|---|---|
agent_id | Yes | The agent that answers. It must belong to your organization. |
agent_version | No | Which version of the agent to run. 0 (the default) is the live draft, a number is a published version, and "latest_published" is resolved when the call is created and recorded on the call. |
dialgem_llm_dynamic_variables | No | Values for the {{variables}} in the agent's prompt. |
metadata | No | Anything you want back on the call record and in webhooks. Dialgem never reads it. |
const { access_token, call_id } = await dialgem.webCalls.create({
agent_id: "AGENT_ID",
agent_version: "latest_published",
dialgem_llm_dynamic_variables: { name: user.firstName, plan: user.plan },
metadata: { visitor: user.id, page: "/pricing" },
})Greet the visitor by name
If the agent's prompt or first message contains {{name}}, the value you pass as name is put there before the call starts.
Hi {{name}}, thanks for calling. I can see you're on the {{plan}} plan. How can I help?If you leave a variable out, its placeholder stays in the text exactly as written, so the agent may say {{plan}} out loud. Give every variable the prompt uses, or set a default on the agent. See Prompt agents for how variables work.
Run a tested version
Use agent_version to pin a call to a published version, so editing the draft does not change what visitors hear. Use "latest_published" to follow your newest release. If the version does not exist, creation answers 422.
Read the result
A web call is an ordinary call. Once it has ended you can fetch it with the call_id your server received:
curl https://api.dialgem.com/v1/calls/CALL_ID \
-H "X-API-Key: $DIALGEM_API_KEY"The record has the transcript, recording, cost, analysis, your metadata and call_type: "web_call". See Calls and call records.
To be told instead of polling, add a webhook endpoint. The call events (call_started, call_ended, call_analyzed) include the full call record, and your metadata comes back on it, so you can match the call to the visitor.