README
Installation
npm i --save los-salesforce
Usage
import { MultipleSMS, SingleSMS } from 'los-salesforce';
const AUTH_URI = '[AUTH_URI]';
const REST_URI = '[REST_URI]';
const SEND_DEFINITION_KEY = '[SEND_DEFINITION_KEY]';
const CLIENT_ID = '[CLIENT_ID]';
const CLIENT_SECRET = '[CLIENT_SECRET]';
const singleSMS = new SingleSMS({
authUri: AUTH_URI,
restUri: REST_URI,
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET
});
singleSMS.send({
definitionKey: SEND_DEFINITION_KEY,
recipient: {
contactKey: "Contact1",
to: "[E.164-based mobile number]",
attributes: {
someKeyWord: 'value'
}
}
}).then((response) => {
console.log("result", response)
}).catch(err => {
console.log("err", err.response.data)
})
const multipleSMS = new MultipleSMS({
authUri: AUTH_URI,
restUri: REST_URI,
clientId: CLIENT_ID,
clientSecret: CLIENT_SECRET
});
multipleSMS.send({
definitionKey: SEND_DEFINITION_KEY,
recipients: [
{
contactKey: "Contact1",
to: "[E.164-based mobile number]",
attributes: {
someKeyWord: 'value'
}
}, {
contactKey: "Contact2",
to: "[E.164-based mobile number]",
attributes: {
someKeyWord: 'value'
}
}
]
}).then((response) => {
console.log("result", response)
}).catch(err => {
console.log("err", err.response.data)
})
References
To use this library a configuration on the salesforce side is required
For more information see the following documentation:
SalesForce Marketing Cloud API - Server-to-Server Integrations with Client Credentials Grant Type
SalesForce Marketing Cloud API - Marketing Cloud Packages
SalesForce Marketing Cloud API - API Integration
SalesForce Marketing Cloud API - SMS - Send a Message to a Single Recipient
SalesForce Marketing Cloud API - SMS - Send a Message to Multiple Recipients