Voice

View as Markdown
Welcome to version 3 of the RELAY SDK

In May 2022, Voice was incorporated into version 3 of the RELAY Realtime Server SDK. If you have an application that runs on the previous version of RELAY for Voice calls, consider upgrading. For some pointers on migrating to this 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.

1import { Voice } from "@signalwire/realtime-api";
2
3const client = new Voice.Client({
4 project: "<project-id>",
5 token: "<api-token>",
6 topics: ["office"],
7});
8
9client.on("call.received", async (call) => {
10 console.log("Got call", call.from, call.to);
11
12 try {
13 await call.answer();
14 console.log("Inbound call answered");
15
16 await call.playTTS({ text: "Hello! This is a test call." });
17 } catch (error) {
18 console.error("Error answering inbound call", error);
19 }
20});

Classes