pyedgeon-service is designed to use twilio + pyedgeon + imgur api to, in order:
- text a twilio number some short (6-20 character) string
- receive a sms message with twilio that routes the request to an http endpoint (in this case serving a localhost port using ngrok)
- parse the body and metadata from that text message into a python dict using flask
- validate the input text
- send the input text through pyedgeon and create an optical illusion in the filesystem
- upload the optical illusion to imgur and receive the link
- formulate a messaging rsponse that includes a body response text and the media url
- send the response back through the twilio webhook and route to the originating phone number
- message appears as an optical illusion to the originating phone number
You must set up imgur API keys and a twilio account and configure their webhooks. I have this service set up with ngrok but many other options are available, including bypassing ngrok and imgur altogether and configuring your own web server that exposes content to the wider web (which is required for twilio MMS).
required python packages:
pip3 install pyedgeon
pip3 install flask
pip3 install imgur-python
pip3 install twilio
After cloning the repository, you must set the following imgur environment variables in your system after creating an application:
export IMGUR_ID="XXXXXXXXXXXXXXXXXXXXXXXXXXX"
export IMGUR_SECRET="XXXXXXXXXXXXXXXXXXXXXXXXXXX"
Run ngrok first and use the website it gives you as the twilio "a message comes in" webhook and connect it to the flask endpoint, like
http://x1x2x3x4x5.ngrok.io/sms
Note: you can use the anonymous API with imgur, it's a little easier in that it doesn't need refresh tokens, but you lose the ability to post as a particular user.
This is essential. You can use the free tier (which only supports 1 number to receive texts from).