Skip to main content

Voice

Welcome to the latest version of the RELAY SDK

In May 2022, Voice was incorporated into the latest version of the RELAY Realtime Server SDK. If you have an application that runs on the previous version of RELAY for Voice calls, consider upgrading to the latest. For some pointers on migrating to this new version, please read our post "Upgrade Your RELAY Game".

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" topic, and immediately plays some speech.

import { Voice } from "@signalwire/realtime-api";

const client = new Voice.Client({
project: "<project-id>",
token: "<api-token>",
topics: ["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);
}
});

Classes