unreceive

View as MarkdownOpen in Claude

Unsubscribe from contexts for inbound call and message events. Sends a signalwire.unreceive request to stop receiving events on the specified contexts. This is the inverse of receive().

After unsubscribing, inbound calls routed to those contexts will no longer trigger the onCall() handler on this client.

Parameters

contexts
string[]Required

List of context names to unsubscribe from. If the list is empty, the method returns immediately without sending a request.

Returns

Promise<void>

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['sales', 'support', 'billing']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11
12 // Dynamically unsubscribe from "billing" after the first call
13 await client.unreceive(['billing']);
14 console.log('Unsubscribed from billing context');
15
16 await call.hangup();
17});
18
19await client.run();