const accountSid = ‘your_account_sid’;
const authToken = ‘your_auth_token’;
const client = require(‘twilio’)(accountSid, authToken);
client.messages
.create({
body: ‘Hello from Twilio!’,
from: ‘+1your_twilio_number’,
to: ‘+1recipient_phone_number’
})
.then(message => console.log(message.sid));
In this code, you will need to replace your_account_sid
and your_auth_token
with your Twilio account SID and auth token, respectively. You will also need to replace your_twilio_number
with your Twilio phone number, and recipient_phone_number
with the recipient’s phone number. Once you have set up the API credentials and phone numbers, this code can be used to send automated text messages using the Twilio API.