Node.js
Send SMS with Node.js
Learn how to send your first SMS using the CCAI Node.js SDK
Prerequisites
To get the most out of this guide, you'll need to:
- Sign up for a CCAI Paid Plan
- Create an API Key
1. Install
Get the CCAI Node.js SDK
npm install ccai-node
2. Send SMS message
import { CCAI } from 'ccai-node';
// Initialize the client
const ccai = new CCAI({
clientId: 'YOUR-CLIENT-ID',
apiKey: 'API-KEY-TOKEN'
});
// Send an SMS to multiple recipients
const accounts = [
{
firstName: "John",
lastName: "Doe",
phone: "+15551234567"
}
];
ccai.sms.send(
accounts,
"Hello ${firstName} ${lastName}, this is a test message!",
"Test Campaign"
)
.then(response => console.log('Success:', response))
.catch(error => console.error('Error:', error));
// Send an SMS to a single recipient
ccai.sms.sendSingle(
"Jane",
"Smith",
"+15559876543",
"Hi ${firstName}, thanks for your interest!",
"Single Message Test"
)
.then(response => console.log('Success:', response))
.catch(error => console.error('Error:', error));
3. Try it yourself
See the full source code here.
Updated 6 days ago