Created
January 10, 2022 18:13
-
-
Save RanjanSushant/089462549bd2c4a059bc4420a53361ff to your computer and use it in GitHub Desktop.
Codesphere Twilio NodeJs text demo app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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