Voice
Access the Voice API. You can instantiate a Voice.Client to make or receive calls. Please see Events for the list of events emitted by a Voice.Client object.
Example
The following example answers any call in the "office" context, and immediately plays some speech.
import { Voice } from "@signalwire/realtime-api";
const client = new Voice.Client({
project: "<project-id>",
token: "<api-token>",
contexts: ["office"],
});
client.on("call.received", async (call) => {
console.log("Got call", call.from, call.to);
try {
await call.answer();
console.log("Inbound call answered");
await call.playTTS({ text: "Hello! This is a test call." });
} catch (error) {
console.error("Error answering inbound call", error);
}
});