Happy election day!
We’re excited that it’s finally election day and sons and daughters around the country are casting their vote.
Let your mom know you’re voting by checking in and using #mom!
We’re excited that it’s finally election day and sons and daughters around the country are casting their vote.
Let your mom know you’re voting by checking in and using #mom!
We built and launched the connected apps version of #mom in one long night a few weeks ago and we’d like to walk through some of our code. Foursquare’s connected apps platform is just a few months old and still in developer preview so we wanted to help other developers get started.
Foursquare allows 3rd party apps to (1) receive a push feed of check-ins, (2) reply to check-ins with text and a link to a custom web view or your native app, and (3) post to the activity feed when an user connects or interacts with your service. For #mom, this is exciting because we can suggest that you call your mom after a check-in rather than hope you remember to include “#mom” in the message (aka a shout in foursquare data model land). There are multiple places to provide users value and delight through a backend action, simple prose, and links to your native app or web UI.
We’re going to walk through replying to check-ins, controlling your service from inside foursquare, and creating posts in the activity feed. Our goal was to build this in one night (10pm to sunrise). We’re assuming you’re already connecting users over OAuth, receiving real-time push check-ins, and familiar with foursquare’s data model as we described in our prior technical post.
First, we need to choose if we want to respond to a given check-in (we don’t want to spam!). Foursquare has an extensive venue categorization taxonomy, from broad levels like parks and recreation to granular places like volcanoes; yes, we have users checking in atop hot lava. You can browse the venue categories online, though we queried the JSON API and dumped to Google Docs for easier person and machine-readability.
We spent much of the night crafting close to 60 quirky messages based on the venue’s category. Connect the app and see if you discover them all!
Foursquare orders each Reply based on response time so we need to be speedy. Replies contain a customizable short message with an optional click through link and are displayed asynchronously in the user’s post check-in screen. We noticed this can appear buggy as new replies are rendered as they come in.

We use the click through link as the trigger to send a call or a text depending on our user’s preference. This was tricky because we don’t receive any information from foursquare when the user clicks the link; we only control the URL. Each link therefore needs to be unique per check-in so that we can look up in our database who to call or text and what to say. The links also need to be unguessable, so you can’t go to hashtagmom.com/easy-to-guess and call your friend’s mom. We accomplish this by storing a distinct random string for every check-in, generated by Ruby’s SecureRandom library. We ensure each token is unique by, elegantly, doing mighty brute force— continuously generating tokens until we find one unused. We could improve this by pre-computing a list of tokens or using some kind of UUID if it were a performance bottleneck, but we hit zero conflicts in our testing of 5M tokens and moved on.
Once we generate a link and text, we send a reply to the API endpoint at https://api.foursquare.com/v2/checkins/checkin_id/reply. Composing the request is easy, but we ran into a roadblock getting foursquare to accept it. Unless otherwise instructed, foursquare defaults to their oldest API, so you need to explicitly instruct it to route your request to the correct endpoint version. To use the latest API, send a { :v => date } parameter along with your request, where `date` is the most recent date when your app worked with the newest API. We developed this on August 17th, so we use “20120817”. Having to provide a version date along with “/v2/” in the URL is confusing. All set with constructing the reply? Don’t forget to use https:
After a successful call or text, we wanted to create a Post for that check-in, which looks like an auto-generated comment in the activity feed on both mobile and web. This is much simpler than sending replies and can include custom text and a custom link. There is a lot of new jargon in terms of (pun!) ways to communicate with the user but at least the Post syntax is similar to a Reply:
A brief aside— you’re required to provide a privacy and terms of service statement to be officially blessed into their directory. We used Docracy and branched their open privacy statement and adopted it for our use (feel free to branch ours too!).
We’re looking forward to the evolution of the platform and hope to see a full fledged marketplace discovery section within the application, clearer policy about how relevant connected apps are chosen and ordered in the check-in view, and more clever experiences that provide value and do not tire after a few uses. Foursquare uniquely has the attention and context of people when they are at places and we’re excited to see how others bring the joys, efficiency and serendipity of the internet to us when we most and least expect it.
To get started, review their technical documentation and guidelines which gives details and a sense of the spirit they’d like apps to embrace but it’s still very opened ended. If you have questions, please tweet or say hello at the bicoastal foursquare hackathon on Nov 3rd; @jeff_weinstein in SF and @scpike in NYC.
We were super excited to hear about the foursquare connected apps platform a few months back. We wanted to join the fun, so we’re launching a hashtagmom connected app within the foursquare platform.
When you check in to a venue that we think you’re likely interested in telling your mom about (e.g. an airport, train station, hotel, home, etc…) we’ll send you an after check in prompt where you can simply one-click initiate a call or text to your mom. Nothing new to sign up for, just start using it today.
You can still add #mom to your check in message and we’ll call or text your mom letting her know you got there safely from any venue.
Adding third party data and services into the foursquare mobile application opens up new ways people can interact with the world around them. We’re the first Twilio powered foursquare connected app so we’ll post another deep technical dive overviewing how we ported our application to the foursquare platform and what changes we need to make to launch this new way to keep mom in the loop.
We’re interested in ways that location context can be combined with sharing, communication, and other types of channels to enhance our day to day lives.
Let us know what you think.
Safe travels,
Jeff and Steve
p.s. we have dozens of fun reminders to call your mom based on where you check in, see if you can discover them all!
Thanks to the many of you for trying out our fun little service. We’ve received some wonderful tweets, emails, and high fives in the last few months but wanted to share this story since we think it really takes the cake.
We’ve changed the names to protect the innocent. Long story short, we learned that sending flowers has been the largest expense in running this side project: larger than Amazon hosting, Twilio per call and SMS send, and domain registration… combined!

“Hi there,
I hope you get as much amusement out of this as my family did. :) We will be telling this story and laughing about it for years.
My mom loves to know where I am at all times. I don’t mind…my life is not that interesting, haha. She has cancer and I’m six hours away, so whatever makes her more comfortable. I set up “Find My Friends” on our iPhones so she can track me that way, but a week or so ago it didn’t update properly and she was very upset when she thought I was someplace I wasn’t. I read about #mom a few days ago and decided to set it up over the weekend. I did a test check-in and showed my mom how it would look on her phone, but thought I may never have a need for it between Find My Friends and ordinary texting.
On the long drive home yesterday, I decided to stop and meet a friend for dinner. I knew my mom would see my little dot stop moving on Find
My Friends, so I decided to try out #mom when I checked into the restaurant on FourSquare. I sent a message that was something like “Stopping for dinner and visiting Meredith!” My parents know this friend, so I thought they might text me back and tell me to say hi for them, or they might try to respond to the #mom notification and be confused when it didn’t go through, but I’d just explain it to them later.
40 minutes later as I was leaving the restaurant, I checked my phone and saw that I’d just missed a call from my dad. He didn’t leave a voicemail which usually means I don’t need to call him back, but since it’s only been a few minutes I decided to call anyway. He told me my mom had gotten a weird text that was phrased very strangely and he thought I was in trouble. I laughed and explained…apparently my mom had forgotten when I’d shown her how the text would look. He said something about how he had called 911 and the state police and I laughed again, it sounds like something my dad would say as a joke.
Then I realized he was serious.

Apparently the first part of the text that says “Your daughter Abby would like to tell you” made them think a stranger was with me and I was telling them to text something for me. And the last part of the text that says something about a help code made them think I was in trouble and was trying to covertly let them know. He called 911, the state troopers and was about to call some undercover cops they referred him to before he decided to try calling me!
Why didn’t he just call me first? Because mom tried to reply to the text message and it didn’t go through, and she thought she was replying to me and my phone must be disabled. And if I was being abducted, could they believe anything I said anyway? Good grief.
So I spent the rest of my drive (about 4 hours) carefully below the speed limit because I had no clue how I would explain all this to the police if they pulled me over and my name came up!
Anyway, the bottom line is, I would LOVE to see a way to customize the rest of the message that gets sent out. If it had just started with “This is an automatic notification” that would have been so much better for my non-tech savvy, extremely forgetful, overly paranoid parents.
Just had to throw my two cents out there after this experience. :)
Thanks,
-Abby”
We checked the logs and found some enlightening context:
12:31pm: Abby checked into Jackson Plaza and wrote “Stopping for dinner and visiting Meredith! #mom”
We processed the checkin immediately after that. We normally automatically add “This is a service from hashtagmom.com” to the end of all SMS message but since the checkin has a lot of characters (long venue name and medium long message) the total SMS length was greater than 160 characters. So we have a rule that just removes the “This is a service from hashtagmom.com” to attempt to fit it within one SMS.
12:46pm: we get a text message reply back from your mom with the message “K! Who is this???”
12:46pm: we auto replied back with the message:
“Welcome to Twilio SMS. Configure your number’s SMS URL to change this message.
Reply HELP for help.
Reply STOP to unsubscribe.
Msg&Data rates may apply.”
I can totally understand how this would have created an issue. We’re considering doing a few things in the future depending on what is technically feasible:
1. Change the message people get when they text our number to be something friendly
2. Redirect the text messages from a mom back to the son or daughter
3. Send two text messages when it’s longer than one to ensure people know it’s from a service
Well, we were so touched by this story and a bit guilty about our corner case coverage that we reached out to Abby and her mother to try and make this right. We sent her mother flowers from a local florist. We even already had her phone number on file to confirm with the flower delivery company!
Continuing our deeper dive into the nuts and bolts of how we built #mom, let’s walk through how we used the foursquare API. We we wanted the foursquare platform to: (1) handle user authentication, (2) supply general user data, (3) retrieve user checkins, and (4) promote the service by displaying #mom in the friend checkin feed.
The following is a bit of an aside and not specifically related to any particular platform but necessary to understand. You’ve likely connected to Facebook before. You’re on SomeGreatSite.com, they have a connect to Facebook button, you click it, and now you’re redirected to a Facebook page that read, “Hi, would you like SomeGreatSite to have access to x, y, z Facebook permissions?” Yup, hit yes and you’re redirect back to SomeGreatSite.com. This flow is brought to you by OAuth2: check out this technical description and foursquare’s overview. From the developer’s perspective: you a user on your domain and want to query an API on that user’s behalf. Rather than ask for andstore a user name and password, you direct the user to the service and wait to hear back if you have permission or not. If you do get permission, you get a special token that is specific to that user. (Remember going to the arcade as a kid and getting special tokens that only fit into the video game machines?) Now, you can query the other service with this token and act as the user. The developer does not have to see or store the user’s authentication details. If the user wants to revoke your site’s access to the platform, they can just tell the platform to stop accepting that token. Change of password, no problem. Badaboom. 

We built #mom as a lil side project to learn the a few platform APIs and get over our coding writer’s block and wanted to share engineering pointers (get it!) we learned. Let’s start with Twilio!