const headers = {
Authorization: "Bearer al_live_...",
"Content-Type": "application/json",
};
const agent = await fetch("https://api.agentline.cloud/v1/agents", {
method: "POST",
headers,
body: JSON.stringify({
name: "Support Bot",
system_prompt: "You are a helpful assistant.",
initial_greeting: "Hello! How can I help you today?",
}),
}).then((res) => res.json());
await fetch("https://api.agentline.cloud/v1/numbers", {
method: "POST",
headers,
body: JSON.stringify({
agent_id: agent.id,
country: "US",
area_code: "415",
}),
});
const call = await fetch("https://api.agentline.cloud/v1/calls", {
method: "POST",
headers,
body: JSON.stringify({
agent_id: agent.id,
to_number: "+12125557890",
}),
}).then((res) => res.json());
await fetch(`https://api.agentline.cloud/v1/calls/${call.id}/hangup`, {
method: "POST",
headers,
});
const transcript = await fetch(
`https://api.agentline.cloud/v1/calls/${call.id}/transcript`,
{ headers },
).then((res) => res.json());
console.log(transcript);