Skip to main content

Continuing from my previous post on Latitude and Longitude UDA, the process that I was discussing this week was around a company whose employees would go on business trips and they would stay at a hotel.  What they want, was to automate a process that at a particular time of the day, a notification would be sent out to their employee with information on how much it would cost them to get an Uber ride from the hotel they are at and also the duration of the ride to the airport they need to go to.

Uber.jpg

 

Requirements

 

In order to get that information from Uber, you will need to have an Uber account.  You will also need get an Uber Server Token, which is what will be used to send the requests to Uber.

 

To get the API Server Token, go to the Uber API page, and register an app.  This will give your server token that you will use.

 

How does it work?

 

Firstly, there is the URL we will need to build, and we can do that with a Build String action.

 

https://api.uber.com/v1/estimates/price?start_latitude=sLat&start_longitude=sLon&end_latitude=eLat&end_longitude=eLon

 

As you can see, it takes 4 parameters, the Start Latitude and Longitude and the End Latitude and Longitude.  That's where my previous post comes into play.

 

This is not all that is needed.  The result that comes back from Uber is in JSON form.  There's no JSON parser in Nintex Workflow (yet!!).  So I had to be a little creative.  I'm not going to go through all the details of how the UDA works.  Suffice it to say, we take the JSON data, extra data out of it and store it in a collection.  Once we have that, we can iterate through the data and pull out the data we need.

 

I've wrapped this into a User Defined Action, because again, it's reusable in other workflows and it also makes it easier to share here.

 

The UDA takes a number of Input and Output parameters.

UDAParameters.png

We have the To and From positions and also an Uber Class.  That is the type of car you're interested in.  In these, the customer was looking at the uberX car.

 

The output parameters, are a duration (in minutes) and a price estimate.

 

WebRequest.png

You can see from the Web Request action, that we've put in the Url we built up with the Build String action, we've also added a header.  This header, Authorization, is where you add your Uber Server Token.  Make sure that before that, you have the "Token " text also.

 

For those that are interested, to pull out the Name/Value pairs of data from the JSON response, I used the following Regular Expression:

 

(?<Key>/w]+)":"?(?<Value>(g$swd.\-/:_]+(,l,$swd.\-/:_]+)?)+)

 

Pretty right?  I actually found it online and had to tweak it a little.

 

Here is a screenshot of the UDA design.  I zoomed out a lot, so you probably won't see the details.  But you'll be able to download it and import it into your environment.

UDADesign.png

There a few smarts in this, in that it iterates through the results, but once the Uber class is found, it stops the For Each loop. So if you're interested in how that is done, I suggest you look into that.

 

Conclusion

 

As with my previous post, I suggest you make this a little more robust and capture the HTTP status and handle it, and also enable the error handling, just incase.

 

I've attached the UDA to this post, which you need to import into the new User Defined Action designer page.  Once that is done, I've also attached a workflow to this post, which uses both the Latitude and Longitude UDA and the Uber Price Estimate UDA.

 

WorkflowDesign.png

As you can see in the screenshot of the workflow above, we have two calls to the Get Latitude Longitude UDA.  This is because we need a To and From position.  We use a Set a Condition to make sure we have both latitudes and longitudes.  If we do, we then use the Uber Estimate UDA.  Now that we have the information we need, we can use it in a Send Notification action, to notify our employee.  This gives them an idea of the price for the ride to the airport and also the time it should take.  That way, they can make sure they don't miss their flight.

 

In the UDA in this post, I stored my Uber Server Token in a Nintex Workflow Constant.  You will need to modify the Web Request action to make sure you use your server token.

 

Don't have Nintex Workflow and want to try it?  Download the trial here.

Hi Vadim

A great post! Unfortunately I cannot import the Uber_Estimate_UDA.nwf

Not as nwf-workflow and not as renamed .uda file.

I am very interested in this Action below. Can you publish a screenshot? Thank you in advance.

"For those that are interested, to pull out the Name/Value pairs of data from the JSON response, I used the following Regular Expression:

 

(?<Key>;w]+)":"?(?<Value>(($swd.\-/:_]+(,,,$swd.\-/:_]+)?)+)"

Kind regards

Andy


Hi Andreas,

 

Download the Uber Estimate UDA.nwf zip and then unzip it before you try to import it into the UDA workflow designer.

Vadim


Hi Vadim

When I extract the zip file then I receive a .nwf file. The UDA workflow designer demands an .uda file. When I rename the file to .uda it does not work.

Importing the .nwf file (new workflow) does also not work…

Kind regards

Andy

Von: vadim.tabakman@nintex.com

Gesendet: Dienstag, 27. Juni 2017 17:26

An: Muss Andreas <Andreas.Muss@bdo.ch>

Betreff: Re: - Uber Price Estimate UDA

Nintex Community <https://community.nintex.com/?et=blogs.comment.created>

Uber Price Estimate UDA

new comment by Vadim Tabakman<https://community.nintex.com/people/vadim.tabakman@nintex.com?et=blogs.comment.created> - View all comments on this blog post<https://community.nintex.com/community/tech-blog/blog/2015/01/10/uber-price-estimate-uda?commentID=15796&et=blogs.comment.created#comment-15796>


Hey,

when you have a UDA that has a file extension of .nwf, what you need to do is go into the actual designer page.

Manage User Defined Actions -> Click Create (to go to build a new UDA) and in the ribbon, click on Import.  Then import the .nwf file.

That should do it for you.

Vadim


Hey,

Thank you, Vadim. It works…

Have a nice day!

Andy

Von: vadim.tabakman@nintex.com

Gesendet: Mittwoch, 28. Juni 2017 15:19

An: Muss Andreas <Andreas.Muss@bdo.ch>

Betreff: Re: - Uber Price Estimate UDA

Nintex Community <https://community.nintex.com/?et=blogs.comment.created>

Uber Price Estimate UDA

new comment by Vadim Tabakman<https://community.nintex.com/people/vadim.tabakman@nintex.com?et=blogs.comment.created> - View all comments on this blog post<https://community.nintex.com/community/tech-blog/blog/2015/01/10/uber-price-estimate-uda?commentID=15812&et=blogs.comment.created#comment-15812>


I’m trying to implement this in my environment that is on premise using Nintex Workflow 2016.  Unfortunately none of links are working in the article and the images are not rendering.  Any chance I could get an updated page that would allow me to see the entire solution?


Using Nintex Workflow 2016, I'm trying to accomplish this in my on-premises environment. Sadly, none of the article's links are active, and the photos are not rendering. Is there a way you could send me an updated page so I can view the whole solution?


Reply