Releases: signalwire/signalwire-js
@signalwire/[email protected]
Release of the SWAIG SDK
This SWAIG SDK will provide users the tools to build their own SWAIG server in Node.js to help with their AI Agent. Users will be able to define functions for the AI to utilize such as a transfer function, send SMS function, start streaming function, etc...
This SDK implementation simplifies the process of hosting a server for your SignalWire AI Agent to perform server-side processing.
Example
import { SWAIG } from '@signalwire/swaig'
const server = await SWAIG({
user: "<USER_NAME_HERE>",
password: "<PASSWORD_HERE>",
generateMetaDataToken: () => uuid()
})
await server.addFunction({
// user: "<USER_NAME_HERE>",
// password: "<PASSWORD_HERE>",
// token: "<META_DATA_TOKEN>", // to check
name: "get_weather",
purpose: "use when inquired about weather anywhere across the globe",
argument: {
properties: {
location: {
description: "the location to check the weather in",
type: "string"
}
},
type: "object"
},
}, (params) => { /* implementation */ });
await server.run()
The above SWAIG server will expose the routes:
- GET /
- GET /get_weather
When the route /get_weather
is requested from a SignalWire AI agent, it will perform the get_weather
function.
Getting Started
To get started with the SWAIG SDK, please refer to our NPM package here
@signalwire/realtime-api v3.11.0
This new release of version 3.11 of the Realtime SDK introduces improvements and new additions to Voice and Video.
Highlights
Additional Methods Added To CallRecording
- pause: Ability to pause an active recording on a call.
const recording = await call.recordingAudio({ direction: "both"});
...
await recording.pause();
- resume: Ability to resume a paused recording on a call.
const recording = await call.recordingAudio({ direction: "both"});
...
await recording.resume();
detectInterruptions
Addition
This allows the application to restart message delivery to the answering machine when speech activity is detected after the detector is in a READY
state.
// Start the detector
const detector = await call.amd({ detectInterruptions: true})
New Alias For Context: topic
Now context
or contexts
will have a valid alias of topic
or topics
.
import { Voice } from "@signalwire/realtime-api";
const client = new Voice.Client({
project: "<project-id>",
token: "<api-token>",
topics: ["office"],
});
Fixes
- Fix the new zoomed Video layouts to be appropriately centered.
- Improvements to Detector for AMD detections.
@signalwire/realtime-api v3.10.0
This small release of version 3.10 of the Realtime SDK introduces a new method for Voice calls and fixes a Voice bug.
Improvements
We have added the call.pass()
method to pass an incoming call to another RELAY consumer. 6a35f0a3
This will allow a consumer to decline incoming calls without ending the call and redirect the call to another RELAY client.
client.on("call.received", async (call) => {
await call.pass();
});
Fixes
- Fixed an undefined
setPayload
method on the CallTap instance.a7426731
@signalwire/js v3.23.0
Version 3.23 of the JavaScript SDK introduces the groundwork for SignalWire's upcoming UCaaS offering Call Fabric.
Improvements
- Initial changes to set up a global
SignalWire
client.65b0eea5
This will allow users to access Call Fabric to create calls outside of a namespace as they currently do with aVoice.Client
orVideo.Client
. - Added a user-defined refresh token function called
onRefreshToken
to update an access token.b44bd6fb
This is a method on theSignalWire
client mentioned above.
client = await SignalWire({
host: document.getElementById('host').value,
token: document.getElementById('token').value,
rootElement: document.getElementById('rootElement'),
onRefreshToken: async () => {
// Fetch the new token and update the client
const newToken = await fetch('/foo')
await client.updateToken(newToken)
},
})
When the access token is expiring, onRefreshToken
will be called to fetch and set a new token without interruption to the client's operation.
@signalwire/realtime-api v3.9.2
The latest version of the Realtime SDK, version 3.9.2, includes an improvement for RELAY.
Improvements
- We now support call state webhook callbacks with
callStateUrl
andcallStateEvents
parameters ondial
andconnect
Voice Call methods.4e1116b6
Call states you may specify with callStateEvents
include created
, ringing
, answered
, ending
, and ended
.
If callStateUrl
and callStateEvents
parameters are included when creating or connecting a call:
const call = await client.dialPhone({
to: '+123456',
from: '+19876',
timeout: 30,
callStateUrl: 'http://mydomain.com/hook',
callStateEvents: ['ended', 'answered']
})
the RELAY system will make a request to the specified webhook with the following payload:
"params": {
"event_type": "calling.call.state",
"event_channel": "signalwire_...",
"timestamp": 123457.1234,
"space_id": "<UUID>",
"project_id": "<UUID>",
"params": {
"node_id": "<UUID>",
"call_id": "<UUID>",
"tag": "<ID>",
"device": {
"type": "phone",
"params": {
"from_number": "+15551231234",
"to_number": "+15553214321"
}
},
"parent": {
"node_id": "<UUID>",
"call_id": "<UUID>",
"device_type": "phone"
},
"peer": {
"node_id": "<UUID>",
"call_id": "<UUID>"
},
"call_state": "ended",
"start_time": <time in ms>,
"answer_time": <time in ms>,
"end_time": <time in ms>,
"created_by": "dial"
}
}
@signalwire/js v3.22.0
Version 3.22 of the JavaScript SDK features another improvement for Video Room Sessions.
Improvements
- New events keep track of the connected devices' status.
e8141c0e
We have added updated
and disconnected
events for microphone, camera, and speaker devices. When listening for microphone update events with
const roomSession = new Video.RoomSession({
host: YOUR_HOST,
token: YOUR_TOKEN,
...
})
roomSession.on('microphone.updated', (payload) => {
console.debug('>> microphone.updated', payload)
});
roomSession.on('microphone.disconnected', (payload) => {
console.debug('>> microphone.disconnected', payload)
});
you will receive the following event payload if a microphone is updated:
{
previous: {
label: 'microphone array',
deviceId: '35e85417-09cf-4b07-8f21-d3c16809e5a8'
},
current: {
label: 'headset',
deviceId: '4a829c9f-812c-49d7-b272-e3077213c55e'
},
}
If the microphone is then disconnected, you will receive the following event:
{
label: 'headset',
deviceId: '4a829c9f-812c-49d7-b272-e3077213c55e'
}
@signalwire/realtime-api v3.9.1
@signalwire/js v3.21.0
Today's JavaScript SDK release includes an improvement for Video and a small fix.
Improvements
- The new method
setLocalStream
has been added to the VideoRoomSession
object to update the local media stream.aaa07479
const canvas = document.createElement("canvas");
// Interact with the canvas
const stream = canvas.captureStream(25); // 25 FPS
await roomSession.setLocalStream(stream);
See the technical reference for additional examples.
Fixes
- Improved reconnection logic under bad network conditions.
f3711f17
@signalwire/realtime-api v3.9.0
Version 3.9 of the RELAY Realtime SDK includes a couple of improvements for Voice calls.
Highlights
Enhanced Speech Recognition
Enhanced speech recognition is now available for speech collection. Prompt
and Collect
methods use a speech configuration object to specify how to collect speech. The new optional key model
enables enhanced speech recognition at an added cost with any of three possible values: enhanced
, enhanced.phone_call
, or enhanced.video
. phone_call
optimizes speech recognition for phone calls at an 8khz sample rate. video
optimizes speech recognition for video calls at a 16khz sample rate. The value enhanced
will automatically detect whether to optimize with the phone call or video setting. 4e8e5b0d
const collect = await call.collect({
speech: {
endSilenceTimeout: 1,
speechTimeout: 60,
model: "enhanced",
hints: ["one", "two", "three", "four", "five"]
},
});
const result = await collect.ended();
See our Voice pricing page for pricing information on advanced features.
Set a Maximum Price per Minute
The parameter maxPricePerMinute
has been added to call.dial
and call.connect
methods to allow users to set a maximum price limit for a call to be created. If the rate for the call is greater than this value, the call will not be created. aa31e1a0
try {
const call = await client.dialPhone({
from: "+YYYYYYYYYY",
to: "+XXXXXXXXXX",
timeout: 30,
maxPricePerMinute: 0.0075,
});
} catch (e) {
console.log("Call not completed.");
}
The cost of a call can vary by rate center and call features. In the example above, if the call charge is greater than $0.0075, the call is not created, and a 30010 error will be returned with the message, "MaxPricePerMinute was exceeded. This call's cost is XX."
@signalwire/js v3.20.0
Version 3.20 of the JavaScript SDK includes a small new feature for Video: local video stream mirroring.
Mirroring the Local Video Stream
We have exposed the property localOverlay
on a Video RoomSession
object. The method setMirrored
on this new property allows a user to mirror their local video overlay. 2e58a76b
await roomSession.localOverlay.setMirrored(true);
The mirrored local stream is sent to the SignalWire Multipoint Control Unit (MCU), muxed into a single unified stream, and visible to all participants.
You can also unset mirroring with
await roomSession.localOverlay.setMirrored(false);