Twitter Updates with Twitter Out | Boomerang Notification Services for SQL Server

Post a Twitter Status Update

Introduction

Interesting and innovative uses of Twitter have recently emerged and many organizations are today trying to figure out how to best use social networking technologies. In this article we will demonstrate a hassle free way to post a Twitter status update using the Boomerang framework and few lines of T-SQL.

To make a status update to a Twitter account using the Boomerang notification framework and MS SQL is a simple and straightforward process. As an IT professional you will interact with the Boomerang SQL database. Each table in the database has its unique function like Email Out, Twitt Out, Fax Out, File Out, Print Out, Email In and Twitt In. In addition to these tables representing services there is an Event Master table used for managing events and Event Status and Event log for status and transaction log.

In this example we will be using two different services: Twitter Out i.e. post Twitter status update and Email Out i.e. send email. The Twitter and Email out services is represented by the following tables Boomerang.dbo.OUT_TWIT and Boomerang.dbo.OUT_EMAIL.

Each instance of Boomerang may be associated with one Twitter account. To use the Twitter Out (and In) service in Boomerang you will have to authorize Boomerang to send and receive on behalf of a particular Twitter account. This is done by means of Open Authentication standard that is supported by both Twitter and Boomerang.

Basic Twitter Update

To make a status update to the Twitter account associated with Boomerang simply create a new event, insert the status update into table OUT_TWIT and then release the event.

Example:

-- Twitter Updates with Twitter Out ---------------------------
-- Declare Key's  ---------------------------------------------
declare @gKey uniqueidentifier; set @gKey = newid()
declare @jKey uniqueidentifier; set @jKey = newid()
 
--- Create new Event
insert EVENT_MASTER (gKey) values (@gKey)
-- Twitter Status Update
insert OUT_TWIT(gKey, jKey, Status) values(@gKey, @jKey, 'test message')
-- Release Event for processing
update EVENT_MASTER set Status=0 where gKey=@gKey

Result:

Twitter Updates | Boomerang Notification Framework

Multiple Jobs in one Event

To combine two or more jobs simply add a second insert statement and appropriate keys. In the sample below a Twitter status update and a email notification are created simultaneously.

-- Twitter Updates with Twitter Out ---------------------------
-- Declare Key's  ---------------------------------------------
declare @gKey uniqueidentifier; set @gKey = newid()
declare @jKeyTwitt uniqueidentifier; set @jKeyTwitt = newid()
declare @jKeyEmail uniqueidentifier; set @jKeyEmail = newid()
declare @StatusUpd nvarchar(50); set @StatusUpd='test message no 2'
 
--- Create new Event
insert EVENT_MASTER (gKey) values (@gKey)
 
-- Twitter Status Update
insert OUT_TWIT(gKey, jKey, Status) 
values(@gKey, @jKeyTwitt, @StatusUpd)
 
-- Send notification email out
insert OUT_EMAIL(gKey, jKey, Subject, Body) 
values (@gKey, @jKeyEmail, 'Twitter Status Update', 'The following Twitter messages:' + @StatusUpd)
insert OUT_EMAIL_RECIPIENT(jKey, Email) 
values (@jKeyEmail, 'info@fuel9.com')
 
-- Release Event for processing
update EVENT_MASTER set Status=0 where gKey=@gKey

Result:

Twitter Updates | Boomerang Notification Framework

Twitter Updates | Boomerang Notification Framework

Conclusion

Boomerang takes away the chore of writing complex code to interface with Twitter and other notification infrastructure like e-mail, printers, file and fax servers. By means of the Boomerang framework IT Professionals can create robust and dynamic notification solution with a minimum amount of T-SQL code.

Boomerang’s Twitter Out feature can easily be used to automate and dynamically post Twitter updates. As illustrated above we posted a twitter status update using five lines and twitter status updates plus a e-mail notification with a handful of additional lines.

References

Download Sample

Twitter Out Sample