Fancify Your Festive Messages with this Python and SMS Script

Fancify Your Festive Messages with this Python and SMS Script

Published December 21, 2018 by Aaron Bassett
Categories:

๐•„๐•’๐•œ๐•– ๐•ช๐• ๐•ฆ๐•ฃ ๐•—๐•–๐•ค๐•ฅ๐•š๐•ง๐•– ๐•Š๐•„๐•Š ๐•ค๐•ฅ๐•’๐•Ÿ๐••-๐• ๐•ฆ๐•ฅ ๐•ฅ๐•™๐•š๐•ค ๐•ช๐•–๐•’๐•ฃ ๐•จ๐•š๐•ฅ๐•™ ๐•’ ๐•๐•š๐•ฅ๐•ฅ๐•๐•– ๐•“๐•š๐•ฅ ๐• ๐•— ๐•ฆ๐•Ÿ๐•š๐•”๐• ๐••๐•– ๐•ฅ๐•ฃ๐•š๐•”๐•œ๐•–๐•ฃ๐•ช!


Telecoms providers see some of the highest volume of SMS on Christmas Day and New Year’s Eve. So it’s likely your friends, and family members are going to be receiving many messages, not just yours. However, with a little Python, the Nexmo SMS API, and some Unicode trickery we can make your message stand out from the crowd.

๐Ÿ…ถ๐Ÿ…ด๐Ÿ†ƒ๐Ÿ†ƒ๐Ÿ…ธ๐Ÿ…ฝ๐Ÿ…ถ ๐Ÿ†‚๐Ÿ†ƒ๐Ÿ…ฐ๐Ÿ†๐Ÿ†ƒ๐Ÿ…ด๐Ÿ…ณ

You can view the entire script as a gist. To run locally, you’ll need Python 3 and the Nexmo Python client as well as Click.

Don’t forget to set environmental variables for NEXMO_KEY and NEXMO_SECRET, these values can be found on the Nexmo dashboard. Once you have the dependencies installed and the API values set you can run the script with the command:

๐•ฌ๐–›๐–†๐–Ž๐–‘๐–†๐–‡๐–‘๐–Š ๐•ฑ๐–”๐–“๐–™๐–˜

I’ve added 6 different fonts to the script as examples, but a search for “Unicode fancy text” turns up plenty of others you can add.

Screeenshot of SMS messages with custom fonts

๐•Š๐•ฅ๐•–๐•ก๐•ก๐•š๐•Ÿ๐•˜ ๐•‹๐•™๐•ฃ๐• ๐•ฆ๐•˜๐•™ ๐•ฅ๐•™๐•– โ„‚๐• ๐••๐•–

The stack of decorators is how we define our Click command. We’re using a type of click.Choice for the font to limit the values to the keys of our font dictionaries that we’ll look at next.

Here we define our fonts in both lower and uppercase. We’re going to reference them later using fonts_lowercase[font] so the key must match exactly the string passed into the command.

We iterate over each letter from A-Z and do a string.replace on the message using the index of the letter (“a” equals 0, “b” equals 1, and so on) to find the correct letter in our fonts_lowercase[font] string. We make this loop twice, once for lowercase letters and once for uppercase.

Finally, we send our SMS. You can supply any alphanumeric string for the sender, but if you would like the message to appear as though you’ve sent it from your phone, and to ensure that the recipient can reply, you should set the sender to be your mobile number in the E.164 international format.

โ„ฑ๐’พ๐“ƒ๐’พ๐“ˆ๐’ฝ๐’พ๐“ƒโ„Š ๐’ฐ๐“…

This Unicode text also works on Facebook and WhatsApp using our Messages API, so you could make your Facebook Messenger bot seem a bit more ฦˆสษฎษ›ส€ึ„สŠีผำ„, or add a ๐•ฅ๐• ๐•ฆ๐•”๐•™ ๐• ๐•— ๐•”๐•๐•’๐•ค๐•ค to your WhatsApp messages.

Leave a Reply

Your email address will not be published.