I don’t use WhatsApp much[1], but when I saw the app’s documentation last night with a mention of the URL scheme, I thought I could play around with it a little bit.
The WhatsApp URL scheme is extremely basic and there’s one part that I can’t get to work. The scheme itself is, unsurprisingly, whatsapp://
– which you can use from Launch Center Pro if you simply want to launch WhatsApp. There are also parameters to do stuff with the URL scheme: text
lets you pass along a (properly encoded) text message that will be automatically inserted in the compose field of the app; abid
lets you specificy an “Address Book ID” to send a message to a specific contact.
The WhatsApp team explains:
Address book ID of contact to start a chat with. If contact with this ID has only one whatsapp-able phone number, application will open a conversation with that contact. If contact with this ID has more than one whatsapp-able phone numbers, application will present a menu with all phone numbers available for chat. If contact has no whatsapp-able phone numbers, or contact with this ID does not exist, or this parameter is missing, application will present contact picker listing all contacts available for chat via WhatsApp.
I thought that something like the following URL would have let me send the text message “Test” to my contact “Alex”:
whatsapp://send?abid=Alex&text=Test
But, in practice, I wasn’t able to get the abid
parameter to work. I have tried with phone numbers, percent-encoded names and phone numbers, email addresses, but I can’t get WhatsApp to recognize the abid
parameter I pass along, as the app continues to present a contact picker. Therefore, for the purpose of this post, I will show you how to send text to WhatsApp, choosing a recipient from the app’s built-in contact picker. If you manage to get abid
to work, please let me know.
The URL scheme and text
parameter can be easily integrated with apps like Launch Center Pro and Drafts. In Launch Center Pro, create an action that lets you write a message in a keyboard prompt, launching WhatsApp with your text already there:
whatsapp://send?text=[[prompt]]
Whereas in Drafts, you can use the app’s tags to send the contents of a draft to WhatsApp with a URL action:
whatsapp://send?text=[[draft]]
If you want to go one step further, you can use a bookmarklet to send the URL of the current webpage to a contact in your WhatsApp address book:
javascript:window.location='whatsapp://send?text='+encodeURIComponent(location.href);
Update: Thanks to reader Ernesto Miquel, I managed to get the “Address Book ID” parameter to work. Essentially, the ID is a unique string that WhatsApp associates with each contact in your buddy list. While it may be possible for developers to get this ID with the iOS SDK, there is a workaround for normal users as well.
With the latest update, WhatsApp lets you backup your chat history to iCloud, and, as we know, iCloud data can be browsed on a Mac inside the Mobile Documents folder. To find the ID of a WhatsApp user, you’ll need to back up WhatsApp to iCloud, then find the WhatsApp folder on your Mac’s Mobile Documents folder; inside that folder, navigate to Accounts, then your account’s name or phone number, then “backup”, and you’ll find a file called ChatStorage.sqlite. Copy the file, and download the free SQLite Database Browser for Mac.
Open the file, click Browse Data, and choose “ZWACHATSESSION” from the Table dropdown menu. Here, you’ll find the chat sessions you’ve backed up, with fields such as “partner name” and “last message”. Alongside these fields, you’ll also see “ZCONTACTABID”, which for me was a series of three digits-long IDs for my WhatsApp contacts.
With the ID, you can then tweak the URL scheme and launch WhatsApp with a message composed in Launch Center Pro/Drafts and directly into a specific chat session:
whatsapp://send?abid=122&text=[[prompt]]
WhatsApp is free on the App Store.
- “Much” as in only a couple of times each day. From what I’ve seen, the service has been more reliable than Apple’s iMessage (I’ve never seen a WhatsApp downtime myself) and the app’s media attachment options make more sense than Messages’ for me. Too bad it’s got no iPad or Mac clients. ↩︎