Programmable SMS and Voice

Getting Started with SMS and Voice Programmable Communications

Published March 03, 2017 by Phil Leggetter

We recently ran a webinar with David Leary from Intuit Developer to go over the basics of using the Nexmo SMS and Voice APIs. If you are planning to attend the upcoming Intuit Small Business Hack and want a heads-up of what’s possible, or if you’re just interested in getting a quick overview of SMS and Voice programmable communications with Nexmo, here are the sections of the webinar that directly address sending an SMS, receiving an SMS, making an outbound phone call and receiving an inbound phone call. All examples also come with code snippets and links to further in-depth reading.

How to Send an SMS

This section of the webinar covers how to send an outbound SMS. It covers using alphanumeric senders and using a number that has been purchased from Nexmo as the from number.

js
const Nexmo = require('nexmo');

const nexmo = new Nexmo({
apiKey: API_KEY,
apiSecret: API_SECRET,
}, {debug: true});

nexmo.message.sendSms(
FROM_NUMBER,
TO_NUMBER,
'Hello from @leggetter', (error, result) => {
if(error) {
console.error(error);
}
else {
console.log(result);
}
});

You can find more info on receiving an SMS in our post on receiving an SMS with Node.JS, the SMS API guide and SMS API reference.

How to Make an Outbound Phone Call

Here's how to make an outbound phone call using the Nexmo Voice API.

js
const Nexmo = require(‘nexmo’);

const nexmo = new Nexmo({
apiKey: API_KEY,
apiSecret: API_SECRET,
applicationId: APPLICATION_ID,
privateKey: PRIVATE_KEY
});

nexmo.calls.create({
to: [{
type: ‘phone’,
number: TO_NUMBER
}],
from: {
type: ‘phone’,
number: FROM_NUMBER
},
answer_url: [‘https://nexmo-community.github.io/ncco-examples/conference.json’]
}, (err, res) => {
if(err) { console.error(err); }
else { console.log(res); }
});

More info on receiving an inbound phone call is covered in our post on receiving an inbound phone call with Node.JS, in the Voice inbound phone call API guide and the Voice API reference. The above example also mentions record, talk, stream and other NCCO actions. So, take a look at the NCCO reference for information on controlling Nexmo conversations and calls.

More Programmable Communications Goodness!

There’s lots more information about Nexmo APIs in the docs that haven’t been mentioned above. For example, the Verify API for 2FA and one-time passwords and Number Insight for looking up information on phone numbers. We’ve also got a selection of programmable communications tutorials that cover building specific communications use cases such as private voice communications, SMS customer support, interactive voice response, and more using the Nexmo APIs.

If you’re going to Small Business Hack, good luck, and we’ll see you there. If you just dropped by to learn about programmable communications we hope you find this useful. Either way, feel free to join the Nexmo Community Slack if you have any questions.

Nexmo Logo