What’s your message? Code, Campaigns and Business….

What’s the better way to spend a Thursday morning than to write some python code which can read my demo customers from a file and their birth date, then send them a 50% discount if today is their birthday, which in turns gets them to spend some money in store or at least appreciate your birthday greeting.

Raise your hands…Who doesn’t like more business…?

For this, I decided to use MessageMedia’s REST API which does this job beautifully. The use case was very very simple. Read a file which has customer name, birth date and phone number and if today is their birthday, send them a 15% discount offer via text. I should say that MessageMedia’s REST API does lots more things than that and can easily be integrated with other Software Solutions to provide a rich/automated experience.

So here is my config file. As we can see, Ben and BdayBoy has their birthday today (12 Oct) but not Anshu (your day will come Anshu..I promise!)

$ cat bday.csv 

And here is my code. I used my own credentials but to access the API, an API key and secret are required. You will need to contact MessageMedia Support support@messagemedia.com with your account name to request access if you wanted to give this a try.

This example uses Basic Auth but you can use HMAC if you wish.

All the steps to deal with API are at: https://developers.messagemedia.com/code/api-documentation/ and they are very easy to follow.

$ cat bdaymm.py 
#!/usr/bin/env python

# Super simple code 

import base64
import csv
import time
import requests

url = 'http://api.messagemedia.com/v1/messages'

BASECODED = base64.b64encode(b'username:password')

headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Basic %s' %(BASECODED)

def send_message(name, number):
    data = '''{
      "messages": [
          "content": "Hello %s, The team from Wowsers would like to wish you a Happy Birthday.Use this text message to receive 50 percent off your next purchase at any Wowsers Store.",
          "destination_number": "%s",
          "format": "SMS"
    }''' %(name, number)

    sendit = requests.post(url, data=data, headers=headers)

    print "Message sent to %s as its %s's Birthday Today!" %(name, name)

with open('bday.csv', 'rb') as csvfile:
    datareader = csv.reader(csvfile, delimiter=',', quotechar='|')
    for row in datareader:
        Id = int(row[0])
        name = str(row[1])
        number = int(row[2])
        DOB = row[3]
        TODAY = time.strftime("%d/%m")
        if TODAY == DOB:
            send_message(name, number)

What this does:

$ ./bdaymm.py 
Message sent to Ben as its Ben's Birthday Today!
Message sent to BdayBoy as its BdayBoy's Birthday Today!

How it looks one the other side: **of course I used the same number for two customers. 🙂

It’s customised, customers see their name and it is almost instant delivery via MessageMedia’s Gateway System.

I like personalised SMS’s better than emails as SMS’s have more chances of people opening it than an email!

If what you see above runs your imagination wild or if you would like to integrate a advanced, fast and reliable SMS solution to your business, do try MessageMedia’s Free Trial at https://www.messagemedia.com.au/ or better call  1300 558 895 so you can integrate some more smartness to your business.

Here are some of the ways you/your business can use MessageMedia’s SMS Solutionsand grow faster.

Lets talk about “Text” Baby!

Continue reading...

Managing API documentation over multiple teams
Bec Martin
September 12, 2019
Your first Django project
Natalie Byrgiotis
July 08, 2019