stephjs / sms-hype-mondays-up

tiny API: SMS-HMU aka Sunday scaries Messaging Service to Hype Mondays Up! πŸŽ‰

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tiny API: SMS-HMU aka Sunday scaries Messaging Service to Hype Mondays Up! πŸŽ‰

The WHY

I get major Sunday scaries πŸ₯Ί, so I'm building this SMS-HMU API to send myself funny / motivational text messages to hype me up every Monday. Feel free to fork this as starter code for whatever text message app you're building! 😁

Technologies used

I built this tiny but mighty SMS (short message service) API on top of AWS SNS (Amazon Simple Notification Service).

How do I use the API?

Pass the API a phone number and message, and that number will receive a text with the message. πŸ“²

This query: 'http://localhost:3000/?message=hello%20world&number=15555555555' would send 'hello world' to +1 (555) 555-5555

Tiny Tutorial

  1. Create a starter project
  • npm init
  1. Install express and nodemon
  • npm i express nodemon
  • add a start script to package.json "start": "nodemon app.js"
  • copy/pasta the starter express server code into app.js
  1. Install dotenv and create .env and .gitignore files
  • npm i dotenv
  • touch .env .gitignore
  • IMPORTANT: add .env to the .gitignore so you don't leak your creds
  • require dotenv in app.js: require('dotenv').config();
  1. Create an IAM user for the project
  • sign into the AWS IAM Console
  • create an IAM group / user with programatic SNS admin access
  • copy/pasta the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY into the .env file
  1. npm i aws-sdk
  • paste the aws-sdk starter code into app.js to check whether you've set your credentials correctly in .env
  • Saving your changes should trigger console logged
  1. Visit the AWS SNS Console.
  • Review SMS pricing docs. As of Jan 2021, Your first 100 SMS messages sent to US phone numbers each month are free.
  • SNS is a regional service. Visit the AWS SNS Console and use the upper right hand dropdown to find the closest available service region to you.
  • add your region to the .env file ex: AWS_REGION=us-west-2
  1. Write API code.
  1. Test your app:
  1. Deploy!

About

tiny API: SMS-HMU aka Sunday scaries Messaging Service to Hype Mondays Up! πŸŽ‰

License:MIT License


Languages

Language:JavaScript 68.3%Language:Shell 31.7%