Send Phone Call Reminders Using the RingCentral Softphone SDK

Tyler Liu
RingCentral Developers
3 min readNov 26, 2019

There are several ways to send reminders, such as mail, email, SMS & phone call. Email & SMS are very popular forms of reminders, but they have some disadvantages. For example, even if your email & SMS are delivered, there is no guarantee that they will be read (in time). So sometimes we need to resort to phone call reminders.

In this article, I’m going to show you how to send phone call reminders. I’m splitting this article into three parts: What is the RingCentral Softphone SDK, how do you send audio via the RingCentral Softphone SDK and how to generate audio dynamically.

RingCentral Softphone SDK

The RingCentral Softphone SDK allows you to create a RingCentral softphone with just a few lines of code.

Please note that, the RingCentral softphone SDK is available in JavaScript and GoLang. The JavaScript version is more feature-rich and mature, so we will use it in this article.

const rc = new RingCentral({
server: process.env.RINGCENTRAL_SERVER_URL,
clientId: process.env.RINGCENTRAL_CLIENT_ID,
clientSecret: process.env.RINGCENTRAL_CLIENT_SECRET
})
;(async () => {
await rc.login({
username: process.env.RINGCENTRAL_USERNAME,
extension: process.env.RINGCENTRAL_EXTENSION,
password: process.env.RINGCENTRAL_PASSWORD
})
const softphone = new Softphone(rc)
await softphone.register()
await rc.logout()
// do something with the softphone})()

The RingCentral softphone has many capabilities such as making an outbound phone call, taking an inbound phone call, getting real time audio, sending audio to a remote peer and much more. In this article we will be focusing on how to send audio to a remote peer.

Send audio file to a remote peer

Let’s say you have a pre-recorded audio file that you want to send to a remote peer, the RingCentral softphone SDK will allow you to do that. Before we can dive into the code, we also need to know the node-webrtc-audio-stream-source library. Simply put, this library allows you to use any audio stream as a WebRTC audio source.

With an audio file test.wav, it’s easy to convert it to a WebRTC audio source:

import fs from 'fs'
import RTCAudioSource from 'node-webrtc-audio-stream-source'
const rtcAudioSource = new RTCAudioSource()
const readableStream = fs.createReadStream('test.wav')
rtcAudioSource.addStream(readableStream)

But how can I make a phone call and send the audio over? Here’s how:

const track = rtcAudioSource.createTrack()
const inputAudioStream = new MediaStream()
inputAudioStream.addTrack(track)
softphone.invite("<phone-number-here>", inputAudioStream)

Now another question comes to my mind: how can I create the reminder audio?

Ways to create a reminder audio

First you need to record some audio. Here are some different options for software you can use to record your audio.

Otherwise you can use some text to speech service to convert text to audio. There are lots of TTS service providers — some of them eve provide a free tier.

Another option is if you just want to do a quick test and the audio quality isn’t a high priority, you can use some local text to speech software. For example, you can generate a reminder audio on macOS by executing the following command:

say -o test.wav --data-format=LEI16@48000 "Hello Tyler, you have an appointment with the dentist at 10am tomorrow morning."

You can confirm that the audio file is properly generated by playing it:

play -e signed -c 1 -b 16 -r 48000 test.wav

A working demo

Here is a working demo that we provided in the official repository. Running this demo will make a phone call and once the person answers the phone call, they will hear the pre-recorded audio file.

Summary

In this article, I gave you a brief introduction to the RingCentral Softphone SDK. We explored the possibility of sending audio reminders using the RingCentral Softphone SDK. Lastly, I shared with you some ways to generate a reminder audio file.

Thanks for reading! Please watch and star the RingCentral Softphone SDK if you think it is useful. To learn even more about other features we have make sure to visit our developer site.

Want to stay up to date and in the know about new APIs and features? Join our Game Changer Program and earn great rewards for building your skills and learning more about RingCentral!

--

--