Skip to main content


Bandwidth in the wild: putt-putt edition

George Perry George Perry
George Perry
Bandwidth putt putt blog post

Notice: This post uses a legacy version of our API. Visit out developer portal to view current API documentation.

There are a lot (I mean A LOT) of practical, real-world applications for our APIs. Seriously, we have whole pages of our site dedicated to it (you should check them out some time); that does not, however, mean that there aren’t more….fun ways to use them.

How do I know. Because we recently had a bit of fun with them.

Get in the hole!

At Bandwidth, we like to have fun. Part of that is our annual Spirit Week competition. While this involves a bunch of different challenges, it culminated with a putt-putt course spanning the top two floors of our office here in Raleigh.

One of those holes was created by a team including Brian Rawlins, Brittany Melton, Courtney Walton, Drew Larmore, Tony Barela, and Lu Lan. This spectacular sextet, this stupendous sixsome, this….I’ve run out of names here, but the point is, this team created a hole that required skill and the ability to text.

They came in like a Catapult

There was a lot of creativity that went into the creation of each hole for our course, but the team managed to be creative and show off a fun way to use Bandwidth’s APIs.

So what did they do?

With a little programming, some API calls, a Raspberry Pi, and a servo, they created an interactive putt putt hole that required you to answer a riddle before you could sink your ball.

How’d this work?

Before trying to putt the ball into the hole, you had to make a gate lift. To do that, you had to text a number, answer a question, and, assuming you got it right, a gate would raise, give you 10 seconds to get the ball in before the gate would close again.

But how did they do that?

The team used the Bandwidth Dashboard to order a phone number and enable SMS on it. Using a Raspberry Pi, Lu wrote a Python program in Flask that accepted the text from Catapult and returned the question, accepted the answer, and (again…assuming it was correct) activated the servo to lift the gate.

What did that look like?

Ok, it may not look like much right here, but with a little code, it can do wonders.

Behind the scenes, Lu’s code, paired with Bandwidth’s APIs, powered the whole operation in the blink of an eye.

Code Sample:

questions = {
    2:"What year is it?!",
    3:"What animal is NC State Mascot?",
    4:"When was NC State founded?",
    5:"What month did the blizzard in Raleigh happen in 1915?",
    6:"During New Year, what's the shape of the ball drop?",
    7:"Besides Moore square, what's the name of the other 'square' park in downtown Raleigh?"
answers = {

The code necessary to setup Bandwidth’s messaging API. You can get more info on how to get started with our APIs at 

messaging_api = bandwidth.client('messaging', 'token', 'secret')

Code to set up the flask web server for the text message to call

@app.route('/', methods=['POST'])

def got_a_message_from_someone():
    payload_json = request.get_json()

    text_message = payload_json["text"].lower()
    phone_number = payload_json["from"]

    if(text_message == "play" or text_message == "yes"):
    elif(text_message == "reset"):
      global index_to_use
      index_to_use = 0
      send_a_text_message_or_something(phone_number, "beep boop beep, bot no understand")
    return "",204

def lets_play_a_game(phone_number):
    send_a_text_message_or_something(phone_number, "ok, let's play a game")
    send_a_text_message_or_something(phone_number, questions[index_to_use])

def send_a_text_message_or_something(number, message):
    message_id = messaging_api.send_message(from_ = '+19806430763',
                              to = number,
                              text = message)

Code to move the servo

def move_the_motor_back_forth_and_back_again_and_forth_and_stuff():
    ss = ServoSix()

      ss.set_servo(1, 180)
      ss.set_servo(1, 0)


And when you put it all together, it was a fun, entertaining hole that won one of our awards for the day.

Been to the wild?

Looking for fun ways to use APIs? Need help figuring out how to implement them? Give us a shout and let’s talk it through.

Talk to an expert today!