-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend-sms.js
More file actions
34 lines (30 loc) · 921 Bytes
/
send-sms.js
File metadata and controls
34 lines (30 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const SDK = require('ringcentral')
const dotenv = require('dotenv')
dotenv.config()
const rcsdk = new SDK({
server: process.env.RINGCENTRAL_SERVER_URL,
appKey: process.env.RINGCENTRAL_CLIENT_ID,
appSecret: process.env.RINGCENTRAL_CLIENT_SECRET
})
const platform = rcsdk.platform()
platform.login({
username: process.env.RINGCENTRAL_USERNAME,
extension: process.env.RINGCENTRAL_EXTENSION,
password: process.env.RINGCENTRAL_PASSWORD
}).then(response => {
var params = {
from: { phoneNumber: process.env.RINGCENTRAL_USERNAME },
to: [
{ phoneNumber: process.env.RECIPIENT_PHONE_NUMBER }
],
text: 'This is a test message from Node JS'
}
platform.post('/account/~/extension/~/sms', params)
.then(response => {
console.log('SMS sent. Delivery status: ' + response.json().messageStatus)
}).catch(e => {
console.error(e)
})
}).catch(e => {
console.error(e)
})