hangup

View as Markdown

hangup

  • hangup(reason?): Promise<void>

Hangup the call.

Parameters

reason
"error" | "hangup" | "cancel" | "busy" | "noAnswer" | "decline"Defaults to hangup

Reason for hanging up.

Returns

Promise<void>

Example

In this example, we listen for an incoming call and then hangup right away with a reason of busy.

1import { SignalWire } from "@signalwire/realtime-api";
2
3const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" })
4
5const voiceClient = client.voice;
6
7// Listen for incoming calls
8await voiceClient.listen({
9 topics: ["office"],
10 onCallReceived: async (call) => {
11 // Listen for a status change event on the call
12 await call.listen({
13 onStateChanged: (call) => {
14 console.log("Call state changed:", call.state);
15 }
16 })
17 // Hangup the call
18 await call.hangup("busy");
19 }
20});