Python Messaging Quickstart
Build a simple Python application that receives a message and sends a reply.
You're ready for this quickstart if you've got the following:
A free trial account
A registered application
A configured FreeClimb Number
Your tools and language installed:Trial accounts: A verified number
Clone your quickstart
For this quickstart, clone the repository for Python Receive Message Tutorial using GitHub's interface or git in the command line.
git clone https://github.com/FreeClimbAPI/Python-Receive-Message-Tutorial.git
Configure your credentials as environment variables
Now that you've cloned the repo for your sample app, the next step is to add your API credentials so you can authenticate with FreeClimb. To do this, first copy your account ID and API key from your dashboard homepage.
Set these as environment variables according to your operating system.
ACCOUNT_ID="YOUR-ACCOUNT-TOKEN"
API_KEY="YOUR-API-KEY"
FREECLIMB_NUMBER="YOUR-FREECLIMB-NUMBER"
Make your local server publicly accessible
The fastest way to start testing your FreeClimb application is to temporarily make your local server publicly accessible through a tunneling service. We'll use ngrok to do this. Start by downloading ngrok. Unzip the file to install, then open your terminal and navigate to the directory where you've unzipped ngrok. Use the following command to start a HTTP tunnel on port 3000.
./ngrok http 3000
Once you run ngrok you should receive a response with a public URL, that looks something like this:
ngrok by @inconshreveable
Tunnel Status online
Version 2.0/2.0
Web Interface http://127.0.0.1:4040
Forwarding http://92832de0.ngrok.io -> localhost:3000
Forwarding https://92832de0.ngrok.io -> localhost:3000
Connnections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00
The Forwarding URLs point to your local server. Save the URLs and go on to the next step.
Configure your application's endpoints
Now that you've got a public URL you're ready to configure your application's endpoints. We'll be configuring the smsUrl using your ngrok URL and the route reference /incomingSms
.
Go to the Apps page in your dashboard. You should see your registered FreeClimb app..
Open its App Config, and you'll see its application ID, alias, and some options for URL configuration. Enter your ngrok URL into the smsUrl field, and add the route /incomingSms
at the end of the URL.
https://YOUR-URL.ngrok.io/incomingSms
When you're done the App Config should look something like this:
Save your updated App Config.
Run your app
Once you've updated your App Config you're all ready to run your app! Run the quickstart application with the commands:
pip install -r requirements.txt
python main.py
Using Docker instead?
Follow these instructions:
- Pull docker image from dockerhub
docker pull freeclimbapi/node-sms-quickstart
- Run docker image after replacing placeholder values
docker run -e ACCOUNT_ID=<YOUR_ACCOUNT_ID> -e API_KEY=<YOUR_API_KEY> -e FREECLIMB_NUMBER=<YOUR_FREECLIMB_NUMBER> -p 3000:3000 freeclimbapi/node-sms-quickstart
Once the quickstart app is running, use your verified number to send a message to your configured FreeClimb number. If everything is set up right, you should receive the message "Hello, World!" followed by the text of the message your Verified Number sent.
Congratulations! You've just made your first messaging application!
Next steps
For a more detailed explanation of the code used, see our Receive a Message tutorial.
Updated 2 months ago