Skip to content

Instantly share code, notes, and snippets.

@RanjanSushant
Created January 10, 2022 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RanjanSushant/089462549bd2c4a059bc4420a53361ff to your computer and use it in GitHub Desktop.
Save RanjanSushant/089462549bd2c4a059bc4420a53361ff to your computer and use it in GitHub Desktop.
Codesphere Twilio NodeJs text demo app
// Getting the environment variables from .env file. This needs to be at the top
require('dotenv').config();
// Saving the account sid and auth token values from environment variable to local variables
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
//Twilio client creation
const client = require('twilio')(accountSid, authToken);
// creating the message using the Twilio client
client.messages
.create({
body: "Your message body will go here. Whatever you want to send.",
from: "+15017122661", // Your Twilio trial number here
to: "+15558675310", // Receiver's number here. Verfiied numbers only for Trial account
})
.then(message => console.log(message))
.catch(err => console.log(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment