Contact Sales

All fields are required

Build a Call Forwarder using SignalWire RELAY | SignalWireAdvanced communications from the source. | SignalWire
Developers

Build a Call Forwarder using SignalWire RELAY

A new way to build voice automation using SignalWire RELAY.

What is SignalWire RELAY?

RELAY is the next generation of interactive communication APIs available at SignalWire. It's a real-time web service protocol that provides persistent, asynchronous connections to the SignalWire network.

Most providers use REST APIs that rely on one-way communication. This adds latency and limits the interactivity of real-time events. SignalWire’s RELAY APIs use WebSocket technology, which allows for simultaneous, bi-directional data transmission. Using RELAY, you can deploy reliable, low-latency, real-time communications.

RELAY allows for interactive and advanced command and control. Complete control will enable easy transfers and injections across all endpoints, making it easier and quicker to build applications.

RELAY integrates easily with your products and infrastructure, enabling simple but powerful applications using Artificial Intelligence (AI) tools, data exchange, serverless technologies and more.

Finally, RELAY enables communications tools to perform in the most popular and widely used environments, like web browsers, mobile devices, in the cloud, or within your own infrastructure.

We’ve published a SignalWire RELAY example that can answer a call with text-to-speech before connecting it to a designated number. All you need is a SignalWire account and phone number to get started.

The instructions to run this code are in the SignalWire-Relay-Examples GitHub Repository. In this post we’ll go through all the inner workings of the example and explain how RELAY can supercharge your automation!

Call Forwarder Example

The call forwarder example uses the SignalWire RELAY NodeJS SDK to connect as a RELAY Consumer. A RELAY Consumer is essentially a client connected to the SignalWire RELAY API over WebSockets. This creates a persistent, secure connection that allows the client SDK to subscribe to events and send commands.

RELAY uses Contexts, a named string to separate events to specific consumers for specific types of calls or messages or to scale them independently.

When creating outbound requests, or configuring phone numbers for inbound requests, you can specify the context. RELAY will then deliver that call or event to Consumers that are configured to listen for that context.

The above diagram shows how this example works. The RELAY Consumer first connects to the SignalWire cloud using a Project ID and API Token to authenticate. It then registers the context voice-forwarder.

When an inbound call is made to a SignalWire phone number configured to the context voice-forwarder, the Consumer is notified.

The Consumer has a handler function, onIncomingCall, which uses the RELAY SDK method call.playTTS to play a text-to-speech message to let the caller know they are being connected to another number.

Another RELAY SDK method, call.connect, is used to command the SignalWire cloud to connect the incoming call to a verified number.

If any member of the call disconnects an event, connect.disconnected is sent to the Consumer and the method call.hangup is used to end the call.

SignalWire RELAY gives you a powerful set of tools to build telecommunications automation. Forwarding a call is just the tip of the iceberg. RELAY allows you to automate the sending and receiving of SMS, user input from voice calls, and much more.

You can modify this particular example to pull from a list of verified numbers and direct calls to the appropriate number based on user input. With some of the other features of RELAY, it is also possible to create automation flows that wait until a user performs an action on a website.

Sign up for a free account to start building with RELAY, and join us in our Community Slack or Forum to connect with our team and other members of our community!

Related Articles