Vadim Tabakman

As I work through a process of automating my blog announcements using Nintex Workflow, I've hit a few snags.  First was the previous post - Nintex Workflow URL Encoding User Defined Action.

I'll be sharing my findings in automating this process through some posts on here, and hopefully breaking it up into User Defined Actions so that others can reuse these.

Some of you are aware of Twitter and it's 140 character limit.  Some of my urls can be quite large, so tweeting about a new blog post can quite quickly reach the 140 character maximum.  I needed to find a way to shorten the url, but this had to be done in an automated fashion.

The good folks at to.ly expose a API that will shorten a URL. For those that are interested, here is a link to their API - http://to.ly/api_info.php

Example

The aim is to convert a url like this : "http://vadimtabakman.com/nintex-workflow-url-encoding-user-defined-action.aspx" which is about 78 characters, into some thing small, like http://to.ly/lR84 which is only 17 characters.

Conversion

The original url would take up more than half the space available for a tweet.

Technical Explanation of the User Defined Action

To call to.ly, use a Web Request action, configured to perform a POST to the following URL : http://to.ly/api.php?json=1&longurl=Input URL&callback=?

The Input_URL is a url encoded url that you need shortened.  We also configured the Web Request action to store the HTTP Status so that we can make sure the call worked correctly, making out UDA robust.

Web Request

If the status returned is 200, it was a successful call.  If it's not, we set a return parameter in our UDA so that the calling workflow can cater for this.

When processing the response, you get some JSON data, which we would then need to parse to pull out the shortened url.  Here is what the response will look like:

Web Request Response 

To extract the shorturl, we can use a Regular Expression action, with this expression : (?<=": ")[\w\W]+(?=", ")

Regular Expression

There's a couple more actions to pull out the result from the collection and store it in an output parameter.  You can see if if you download the UDA below and import it into your Nintex Workflow environment. 

Conclusion

You can nowuse the shortened URL to tweet, post on Facebook, Yammer, LinkedIn or use it in email.

The one thing to remember, is that in order for this work, your SharePoint environment needs to be exposed to the internet in order for the Web Request to to.ly to work.

Downloads

Nintex Workflow 2010 - v2.3.9.0

Shorten URL UDA - NWF (Design) Download - import into the designer page

Shorten URL UDA - UDA Download - import into Site Actions->Nintex Workflow 2010->Manage User Defined Actions

Posted by Vadim Tabakman Friday, June 21, 2013 10:53:00 AM Categories: Nintex Workflow Regular Expression Set a Condition User Defined Actions Web Request
Copyright Vadim Tabakman
Rate this Content 0 Votes

Comments

Thursday, December 19, 2013 2:07:49 PM
Ned Humphreys

re: Nintex Workflow - Shorten URL User Defined Action

The URL for this UDA on your UDA listing page is invalid.  This is a useful UDA that I'd hate for others to miss!  Smile

http://www.vadimtabakman.com/user-defined-actions.aspx 

Thursday, December 19, 2013 11:45:06 PM

re: Nintex Workflow - Shorten URL User Defined Action

Hi Ned,

wow good catch.  Thanks so much.  I've updated the link on that page :)

cheers,

Vadim

You must sign in to this site to post comments.
Already Registered?
Sign In
Not Yet Registered?
Register





 

Statistics

  • Entries (249)
  • Comments (1729)

Categories