How to Send SMS Text Messages with AWS Lambda and Python 3.6
Amazon Web Services (AWS) Lambda is a usage-based service that can run arbitrary Python 3.6 code in response to developer-defined events. For example, if a new JPEG file is uploaded to AWS S3 then AWS Lambda can execute Python code to respond to resize the image on S3.
Let’s learn how to use AWS Lambda with a manual test event trigger to send outbound text messages via a Python Lambda function that calls the Twilio SMS REST API.
Getting Started with AWS Lambda
Sign up for a new Amazon Web Services account, which provides a free tier for new users, or sign into your existing AWS account.
After you sign up go to the main Console page that looks like the following screen.
As shown in the screenshot, use the search box with the text “lambda” to find Lambda on the list of services. Click on Lambda to ...
How to Dial and Answer Phone Calls with Spark and Java 8 in IntelliJ
Java web applications can easily dial and receive phone calls by combining the Spark web framework with the Twilio Voice API. Our example phone calls will say a snippet of text then play an MP3 file, but they can easily be modified to provide other useful actions like gathering user input from the number pad or creating conference calls.
Our Project Tools
Our Spark web app will use the Java 8 JDK and Apache Maven so make sure you have those tools installed. If you need to get Java 8 and Apache Maven installed on your Windows machine, check out this tutorial (you can skip over the GWT bits). We will also need the following tools throughout this walkthrough:
How to Install Java 8, Apache Maven and Google Web Toolkit on Windows 10
Do you want to get started developing Java web applications that use Google Web Toolkit (GWT)? This guide walks through how to install a Windows 10 development environment so you can start building your projects.
Tools We’ll Need
We’ll need to install and configure several tools for our development environment:
- Java 8 Java Development Kit (JDK)
- Apache Maven build and configuration tool
- Google Web Toolkit (GWT) web framework
Let’s get started by downloading and installing version 8 of the Java JDK.
Java 8 JDK
Head over to the Java 8 JDK downloads page in your web browser. Read and accept the licensing agreement then proceed with the download for the latest release of the Windows x64 Java SE Development Kit.
When the download completes, run the executable. Allow the installer to make changes to your system.
Move through the installer and when you reach the following screen ...
Localhost Tunneling with Ngrok on Mac OS X
A localhost tunnel comes in handy when you want to share an application running in your local development environment via a publicly-accessible URL. In this quick 2 minute video we will learn how the localhost tunneling tool Ngrok works then download and run it on Mac OS X:
Now you’re ready to share your local in-progress applications with others before you perform a full-blown deployment.
Links & More Resources
We used a couple of resources in the above video:
- Ngrok, the localhost tunneling tool by Alan Shreve
- Python 2.7 SimpleHTTPServer built into stdlib (Python 3 replaces SimpleHTTPServer with http.server)
Learn more about how to configure and use Ngrok with these tutorials:
- Test Your Webhooks Locally with Ngrok
- 6 awesome reasons to use ngrok when testing locally
- How to set up your Python and Flask development environment, including Ngrok
Now that you have Ngrok running on your Mac ...
First Steps with Python and Bottle
Do you want to build your first web application with Python? Or have you been working with a full-featured web framework such as Django or Pyramid and want to try out a microframework? Take four minutes to watch this video and check off “get started using the Bottle web framework” from your 2016 to-do list:
You can snag the code in the video via this GitHub Gist or just copy from here into a file named
import bottle from bottle import route, run, Response app = bottle.default_app() @route("/") def index(): """Returns standard text response to show app is working.""" return Response("My Bottle app is up and running!") if __name__ == '__main__': run(host="127.0.0.1", port=5000, debug=False, reloader=True)
Make sure to
pip install bottlefrom PyPI and then run the following command:
That’s it, 15 lines of ...!-->
How to Make and Receive Phone Calls with Python, Bottle and Twilio Voice
Python web applications that combine the Bottle web framework with the Twilio Voice API can easily make and receive phone calls. Our calls will read a snippet of text then play an MP3 file. The call instructions can be modified to provide other useful actions such as gathering input from the number pad or putting all callers together in a conference call.
Our Project Tools
Our Bottle application will need either Python 2 or 3 to be installed. Python 3 is recommended for new applications. We will also need the following tools throughout this walkthrough:
- Bottle web framework for serving HTTP requests
- Ngrok to create a localhost tunnel to our local development environment
- A free Twilio account to use the Voice web API
- Twilio Python helper library
You can snag all the code for this tutorial in the python-twilio-example-apps GitHub repository. Copy and modify the code however you want – it ...
Getting Started with Python, Bottle and Twilio SMS / MMS
Python applications can easily send and respond to text and picture messages using a web API. Outbound messages are sent through Twilio’s RESTful API, while inbound messages are received by your application when Twilio makes an HTTP POST request. We will walk through how to set up a Bottle web app to handle both SMS and MMS messages.
Tools We Need
You’ll need Python 2 or 3. Although, Python 3 is recommended by the developer community for all new applications. Install one of those two Python versions on your system. We also need the following:
- The Bottle web framework
- Ngrok for localhost tunneling to our web app while it is running on our local development environment
- A free Twilio account to use the messaging API and receive webhooks
- The open source Twilio Python helper library and
- TwiML documentation for responding to inbound Twilio POST requests
All the code ...
How to Add Phone Calling Bots to Slack with Python
Slack is awesome for text and emoji-based conversations with colleagues. However, sometimes it’s far easier to quickly answer a question over the phone. While Slack is just starting to add voice calling between users, there is no way to patch someone in by their good old telephone number. Let’s add phone calls to Slack by creating a bot with Python, Twilio and the Slack Real Time Messaging API.
Tools We Need
Our bot, which we’ll name callbot, requires a few libraries and APIs. To build our bot we need:
- Either Python 2 or 3
- pip and virtualenv to handle the Python application dependencies
- python-phonenumbers to ensure phone numbers are valid
Our Twilio requirements are:
- A free Twilio account for testing your own phone number or an upgraded Twilio account to call any number
- One ...
How to Build an SMS Slack Bot in Python
Bots can be a super useful bridge between Slack channels and external applications. Let’s code a simple Slack bot as a Python application that combines the Slack API with the Twilio SMS API so a user can send and receive Slack messages via SMS.
Tools We Need
Our bot, which we’ll call “twiliobot”, requires Python, Slack and Twilio APIs and libraries. To write and run our Python code we need:
- Either Python 2 or 3
- pip and virtualenv to handle Python application dependencies.
- Flask web microframework, if you’re unfamiliar with Flask, many learning resources are available
The Slack dependencies are:
- Free Slack account with a team on which you have API access or sign up for the Slack Developer Hangout team
- Official Python slackclient code library built by the Slack team
- Slack API ...
Tutorials from Twilio: Live Coding on Twitch This Week
The launch celebration of Tutorials from Twilio continues as the Twilio developer evangelists take you through building their favorites live on Twitch. Join us all week long as we use these amazing new tutorials to equip you with the knowledge you need to add chat to an existing iOS mobile app, implement two-factor authentication in a Rails application, make phone calls from a browser using Python and Django and much more.
Find the schedule of the weeks streams below and we hope you join Team Twilio on Twitch.
Tuesday, March 22nd, 9:30am – 11:30am EDT
Greg Baugues – @gregbaugues
Adding Two Factor Authentication to a Laravel App with Authy
Tuesday, March 22nd, 10:30am – 12:30pm EDT (Archived video here)
Phil Nash – @phil_nash
Two Factor Authentication (2FA) in Ruby on Rails Apps
Wednesday, March 23rd, 9am-12pm EDT
Brent Schooley – @BrentSchooley
Building a chat app with Swift using Twilio IP Messaging ...