Skip to content

Commit 6f57062

Browse files
committed
Implement messaging-service Node code samples
1 parent dfe0840 commit 6f57062

File tree

18 files changed

+276
-0
lines changed

18 files changed

+276
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.alphaSenders
10+
.create({alphaSender: 'My Company'})
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.alphaSenders('AIc781610ec0b3400c9e0cab8e757da937')
10+
.remove()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.alphaSenders('AIc781610ec0b3400c9e0cab8e757da937')
10+
.fetch()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.alphaSenders('AIc781610ec0b3400c9e0cab8e757da937')
10+
.list()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
8+
const opts = {
9+
friendlyName: 'My First Service',
10+
statusCallback: 'http://requestb.in/1234abcd'
11+
};
12+
13+
client.messaging.services.create(opts)
14+
.then(function(response) {
15+
console.log(response);
16+
}).catch(function(error) {
17+
console.log(error);
18+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
8+
client.messaging
9+
.services('MG2172dd2db502e20dd981ef0d67850e1a')
10+
.remove()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
8+
client.messaging
9+
.services('MG2172dd2db502e20dd981ef0d67850e1a')
10+
.fetch()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
8+
client.messaging
9+
.services('MG2172dd2db502e20dd981ef0d67850e1a')
10+
.list()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
const phoneNumbers = ['PN2a0747eba6abf96b7e3c3ff0b4530f6e',
10+
'PN557ce644e5ab84fa21cc21112e22c485',
11+
'PN2a0747eba6abf96b7e3c3ff0b4530f6e'];
12+
13+
phoneNumbers.forEach((phoneNumber) => {
14+
service.phoneNumbers.create({phoneNumberSid: 'PN557ce644e5ab84fa21cc21112e22c485'})
15+
.then(function(response) {
16+
console.log(response);
17+
}).catch(function(error) {
18+
console.log(error);
19+
});
20+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.phoneNumbers.create({phoneNumberSid: 'PN557ce644e5ab84fa21cc21112e22c485'})
10+
.then(function(response) {
11+
console.log(response);
12+
}).catch(function(error) {
13+
console.log(error);
14+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.phoneNumbers('PN557ce644e5ab84fa21cc21112e22c485')
10+
.remove()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.phoneNumbers('PN557ce644e5ab84fa21cc21112e22c485')
10+
.fetch()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.phoneNumbers('PN557ce644e5ab84fa21cc21112e22c485')
10+
.list()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.shortCodes.create({shortCodeSid: 'SC3f94c94562ac88dccf16f8859a1a8b25'})
10+
.then(function(response) {
11+
console.log(response);
12+
}).catch(function(error) {
13+
console.log(error);
14+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
10+
.remove()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
10+
.fetch()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
const service = client.messaging.services('MG2172dd2db502e20dd981ef0d67850e1a');
8+
9+
service.shortCodes('SC3f94c94562ac88dccf16f8859a1a8b25')
10+
.list()
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Download the Node helper library from twilio.com/docs/libraries/node
2+
// These consts are your accountSid and authToken from https://www.twilio.com/console
3+
const accountSid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
4+
const authToken = 'your_auth_token';
5+
6+
const client = require('twilio')(accountSid, authToken);
7+
8+
client.messaging
9+
.services('MG2172dd2db502e20dd981ef0d67850e1a')
10+
.update({inboundRequestUrl: 'http://www.example.com'})
11+
.then(function(response) {
12+
console.log(response);
13+
}).catch(function(error) {
14+
console.log(error);
15+
});

0 commit comments

Comments
 (0)