I have not been blogging very actively lately because I’ve been really busy with ShareMeme and a new product which I am proud to introduce to you: MessagePub
MessagePub is a easy-to-use REST API that lets you send messages to people on different communication platforms. We currently support: AIM, SMS, Google Chat, Twitter, Email, or Phone (text-to-speech). We will keep adding more platforms as we go.
The API lets you schedule messages to be sent in the future, set up an escalation schedule (e.g. if you don’t find this person on AIM, email them 20 minutes later, etc…), and it takes care of saving and sending you back any replies from your recipients.
Because it is a REST API, it can be used very easily with ActiveResource in Ruby. In this blog post, I will go through an example of using ActiveResource to interface with MessagePub. In later blog posts, I will cover the messagepub gem.
For more information on the API and how to use it with other languages besides Ruby, check out the documentation.
In order to use the MessagePub API, you have to sign up on messagepub.com to obtain an API Key. It is free to get started because we give away 100 free credits for your to try it out when you sign up.
Once you have an API Key, you can get started very quickly with ActiveResource. The main resource that you will be interacting with is a Notification. You can create a Notification, list all your Notifications, and get a particular Notification. A notification can have more than one recipient but when you send the messages it will not send the message to all the recipients at the same time. There is an escalation parameter that you can set to determine how long to wait before sending the message to the next recipient. The default value is 10 minutes if you do not explicitly set it. If you want to send the messages to all the recipients at the same time, simply set the escalation for the notification to zero.
Let’s look at some code:
require 'rubygems' require 'activeresource' class Notification < ActiveResource::Base # Remember to put in your API key. self.site = "http://YOURAPIKEY@messagepub.com/" end
Make sure to replace your API key in the URL. That’s it! Now you are ready to start creating notifications.
# Create a new notification
notification = Notification.new(:body => 'You have a message waiting for you in your inbox',
:escalation => 30,
:recipients => {
:recipient => [
{:position => 1, :channel => 'email', :address => 'joe@example.com'},
{:position => 2, :channel => 'twitter', :address => 'sharememeinc'},
{:position => 3, :channel => 'phone', :address => '1234567890'}
]}
)
notification.save
You’ve just created a notification. How easy was that? As soon as you run this code, an email will be sent to joe@example.com. After 30 minutes (since escalation = 30), if Joe never replied or acknowledged receipt of the email, a twitter message will be sent to ‘sharememeinc’. 30 minutes after the twitter message was sent, if ‘sharememeinc’ never replied, MessagePub will call the phone number (’1234567890′) and read them the message.
Of course, if at any point, the recipient acknowledges receipt of the message, the chain is halted.
You don’t always have to take advantage of the escalation feature. If you only need to send the message to one person, just add one recipient and there is no need to specify the position of the recipient. For example, to send a text message to ’12356789′, you can do the following:
notification = Notification.new(:body => 'This is the body of the SMS text message',
:recipients => { :recipient => [{:channel => 'sms', :address => '1234567890'} ]})
notification.save
I hope you will find this helpful and I look forward to hear your feedback on MessagePub.



[...] the MessagePub gem 13 03 2009 In my last post, I showed you how you can use ActiveResource to interact with MessagePub. I’ve also wrote a [...]