Notifications
If you've initialized the SignalWire Client with a subscriber token, you can opt into receiving notifications whenever that subscriber address is called using WebSockets.
The WebSocket notifications are delivered over the WebSocket connection while your application is active, and you have
called the online() method to opt into receiving them.
To receive incoming call notifications over WebSocket, call client.online() with an incomingCallHandlers object:
client.online({
incomingCallHandlers: {
websocket: (callInvite) => {
const callerName = callInvite.invite.details?.caller_id_name;
const callerNumber = callInvite.invite.details?.caller_id_number;
// to accept:
const roomSession = await callInvite.invite.accept(params);
// to reject:
callInvite.invite.reject();
},
},
});
When an incoming call arrives, the websocket handler receives a callInvite object containing:
callInvite.invite.details- call and caller informationIncomingInvitecallInvite.invite.accept()- accepts the call and returns aCallSessioncallInvite.invite.reject()- rejects the call