简体   繁体   中英

New to Twilio and struggling to pass data from database to Twilio so it sends text message with information with a serverless function on Azure

I only started using Twilio last week and am getting confused with how to set up my Twilio account so it can receive information from a database when a field changes and then text it to a number.

I have gone through the docs to set it up with node and can get the text message to be sent if I sent a text to my Twilio number, but getting the data from a different source is seeming a lot harder.

I'm using JavaScript with Windows Azure. Any suggestions are greatly appreciated.

One approach would be to add the Twilio SDK to your Azure function, trigger the function when the database is updated, and use the SMS client to send a message when the function is triggered.

Here is a code sample for sending a simple message from the quickstart docs ( https://www.twilio.com/docs/sms/quickstart/node ):

// Download the helper library from https://www.twilio.com/docs/node/install
// Your Account Sid and Auth Token from twilio.com/console
const accountSid = 'AC0840e531a54515afbda482d80c48fb10';
const authToken = 'your_auth_token';
const client = require('twilio')(accountSid, authToken);

client.messages
  .create({
     body: 'This is the ship that made the Kessel Run in fourteen parsecs?',
     from: '+15017122661',
     to: '+15558675310'
   })
  .then(message => console.log(message.sid))
  .done();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM