Code Challenge: Listen to Incoming Emails with Twilio
SendGrid TeamA lot of cars now provide you with Bluetooth connections to your mobile phone. This gives you the ability to play music from your phone as well as make and answer phone calls. This made me think, what if we could extend this ability to listen and respond to incoming emails? I found it’s actually possible by turning on email forwarding and implementing the SendGrid Parse Webhook and the Twilio API.
Ingredients
- Twilio Account: Twilio is a voice and messaging API service. We use their service to call our phone and dictate the email.
- SendGrid Account: We use the Parse Webhook to create an email address in which all data of emails gets POSTED to our application.
- Mobile Phone: The number that Twilio will call.
Step 1:
The first thing we are going to do is create accounts on Twilio and SendGrid. For a SendGrid account just visit www.sendgrid.com/free.
Step 2:
Get a phone number on Twilio.
Step 3:
Set an incoming email route at https://sendgrid.com/developer/reply
- Hostname: Callme.bymail.in (any email like something@callme.bymail.in will be broken down into individual components and posted to the URL in the field below).
- URL: The url of my application that gets the Posted data and takes some action.
Step 4:
Run the Python Flask code below:
This code gets the email and calls my cell whenever an incoming email happens.
Step 5:
Now you have the ability to listen to emails while driving! Whenever you’re going on a long journey and want to be apprised of whats happening with your email, you can just turn your email forwarding on and have email that would normally be sent to your inbox, sent to the specific email address that calls your phone.