Messaging your phone number from the Twilio api using Javscript
- This assumes that you know how to use the cli/terminal in GNU/Linux
- This also assumes that you use vscode as your IDE
- Finally, this assumes that you already have obtained your TWILIO_ACCOUNT_SID and AUTH_TOKEN
- Install nodejs
sudo apt install nodejs -y
- Install npm
sudo apt install npm -y
- Install Twilio
npm install twilio
- Create a folder in the terminal
mkdir folder name
- CD into that folder
cd folder name
- Make sure to input your twilio_sid_token and auth_token
const client = new Twilio("TWILIO_ACCOUNT_SID", "AUTH_TOKEN");
- Open up vscode in the terminal
code .
- Then run the command
node explore.js
- This will gather your most recent sent messages in Twilio
client.messages
.list()
.then(messages => console.log(`The most recent message is ${messages[0].body}`)
).catch(err => console.error(err));
- You are done