/sms-via-email

Using SendGrid and Twilio to send and receive SMS messages via email.

Primary LanguagePython

About

This code demonstrates how to use SendGrid's "Inbound Parse Webhook" and Twilio SMS to send and receive SMS messages via email.

Setup Tips

  1. Configure your domain to have a subdomain called "sms" that points to "mx.sendgrid.net".

  2. Clone my GitHub repository to your local machine:

     git clone https://github.com/jpf/sms-via-email.git
    
  3. Change in to the sms-via-email directory you just cloned:

     cd sms-via-email
    
  4. If you haven't already, log in to Heroku from your command line:

     heroku login
    
  5. Tell Heroku to create a new application for you:

     heroku create
    
  6. Configure your new Heroku application with your Twilio and SendGrid credentials:

     heroku config:set SENDGRID_USERNAME=
     heroku config:set SENDGRID_PASSWORD=
     heroku config:set TWILIO_ACCOUNT_SID=
     heroku config:set TWILIO_AUTH_TOKEN=
    

    Make sure you put your SendGrid and Twilio authentication credentials after the equals signs above!

  7. Configure your Heroku application with the email domain you configured above.

     heroku config:set EMAIL_DOMAIN=
    

    Your email domain goes after the equals sign above!

  8. Deploy the code you just checked out from GitHub to Heroku:

     git push heroku master
    
  9. Check to see if the code is configured correctly:

     heroku open
    
  10. If a web browser opens and you see the text: “Congratulations, this software appears to be configured correctly.” then you’re almost done.

  11. Take note of the “SendGrid Inbound Parse Webhook URL” and the “Twilio Messaging Request URL”. Use those URLs as the webhook URLs for SendGrid and Twilio.

  12. Rename the "address-book.cfg.sample" to "address-book.cfg" and configure it with your Twilio phone number and your email address. Check that file into git and push your change to Heroku.

    mv address-book.cfg.sample address-book.cfg
    nano address-book.cfg
    git add address-book.cfg
    git commit -m 'updated address book'
    git push heroku master
    
  13. Try sending an SMS to your Twilio phone number, you should get the text you sent in email. The first line of your reply to that email should get send back as a SMS message.