Quickstart, web call
Create an agent and talk to it from a web page. You need an account and an API key.
Create an agent
Create a prompt agent. It needs a name, what it should do, and a voice_id. There is no default voice, so an agent without one cannot speak. Pick one from Voices and put its id where you see VOICE_ID.
curl https://api.dialgem.com/v1/agents \
-H "X-API-Key: $DIALGEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Front desk", "voice_id": "VOICE_ID", "system_prompt": "You answer calls for a dental clinic." }'Allow your website
Tell Dialgem which origins may start calls. Until you do, creating a web call answers 409 web_origins_not_configured.
bash
curl -X PUT https://api.dialgem.com/v1/web-calls/settings \
-H "X-API-Key: $DIALGEM_API_KEY" -H "Content-Type: application/json" \
-d '{ "allowed_origins": ["http://localhost:3000"] }'Create a call from your server
Your server asks for a call and gets back a token that works once, for 60 seconds.
ts
app.post("/api/start-call", async (req, res) => {
const { access_token } = await dialgem.webCalls.create({ agent_id: "AGENT_ID" })
res.type("text").send(access_token)
})Start the call in the browser
ts
import { DialgemCall } from "@dialgem/client"
const call = new DialgemCall({
accessToken: () => fetch("/api/start-call", { method: "POST" }).then((r) => r.text()),
})
call.on("transcript", (t) => console.log(t.role, t.text))
talkButton.onclick = () => call.start() // must run from a clickYour API key stays on your server
The browser only ever holds a token that works for one call, with one agent, once.