

Send an SMS with Guile and Twilio API
source link: https://dev.to/jeremykorwin/send-an-sms-with-guile-and-twilio-api-4eba
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.


Send an SMS with Guile and Twilio API
These last days, I tried to send an SMS with a Guile script.
TL;DR: I succeeded!
Since the code is just a simple HTTP POST request, the longest part should have been the creation of the Twilio account (with a Regulatory Bundle and a phone number).
But in the end, it took me about one evening[1] to set up a development environment with the right dependencies, and then two more evenings to figure out which HTTP headers were needed.
Anyway, here is the script:
;; send-happiness.scm
(use-modules (web client)
(web http)
(ice-9 receive)
(ice-9 iconv)
(gcrypt base64))
(define TWILIO_ACCOUNT_SID "your-account-sid")
(define TWILIO_ACCOUNT_TOKEN "your-account-token")
(define TWILIO_PHONE_NUMBER "your-twilio-phone-number")
(define TWILIO_CREDENTIALS
(base64-encode
(string->bytevector
(simple-format #f "~A:~A" TWILIO_ACCOUNT_SID TWILIO_ACCOUNT_TOKEN) "utf-8"))
(define RECIPIENT_PHONE_NUMBER "a-phone-number")
(define TEXT_MESSAGE "Wish you so much happyness !")
(http-post
(simple-format
#f
"https://api.twilio.com/2010-04-01/Accounts/~A/Messages"
TWILIO_ACCOUNT_SID)
#:headers `((content-type . (application/x-www-form-urlencoded (charset . "utf-8"))
(authorization . (basic . ,TWILIO_CREDENTIALS)))
#:body (simple-format #f "Body=~A&To=~A&From=~A"
TEXT_MESSAGE
RECIPIENT_PHONE_NUMBER
TWILIO_PHONE_NUMBER))
Enter fullscreen mode
Exit fullscreen mode
And how to execute it :
$ guix shell guile gnutls guile-gcrypt -- guile send-happiness.scm
All phone numbers must start with the country indicator. For example +33 for a French number.
[1] the time unit of my Guile tinkering
Thank you very much for reading this article!
Don't hesitate to give me your opinion, suggest an idea for improvement, or ask a question! To do so : contact me.
Don't miss out on the next ones...
- articles via Mastodon @[email protected] and RSS
- screencasts via Peertube [email protected] and RSS
And more importantly, share this blog and tell your friends it's the best blog in the history of Free Software! No kidding!
Recommend
-
9
Short Message Service (SMS) text messages are ubiquitous for communication all over the world. It is easy to send SMS text messages from a Python application using a
-
11
F# + Twilio = SMS Secret SantaMark's Blog Content is considered mobile friendly.
-
7
SMS static site authoring with Twilio and PerlSMS static site authoring with Twilio and Perl I was working with Twilio for another project and got the idea that it might be fun if I could send pictures and text messages to a magic p...
-
14
How to send a SMS using TwilioWhether that be notification, security OTPs or alerts, SMS is one of the best methods of reaching your user base. Adding SMS services requires a backend setup for Twilio or other SMS services. Our goal is to crea...
-
6
How to send sms using Twilio in Node.js Twilio is a platform used by hundreds of thousands of businesses...
-
7
Build an SMS Reminder App using Nodejs, Twilio, and Flybase
-
8
In this article, we are going to learn how we can send SMS or WhatsApp messages with your Node.js app. Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine...
-
10
Signal set to send SMS packing
-
6
Spritely Goblins v0.10, for Guile and Racket!Spritely Institute -- Mon 30 January 2023We are excited to announce Spritely Goblins v0.10, available for both
-
27
How to Send SMS in 30 Seconds with F#
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK