How to create and Advanced service (XaaS) to send SMS with vRealize Automation

Publié le 24 Août 2016

In this article, we are going to show how easy it is to create advanced services in vRealize Automation (vRA). We will take as an example the ability to send text messages. This will showcase how easy it is to create advanced service (XaaS) into vRA which are not related to VM, vSphere, Networks, etc…

This is (one of) the end result:

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

So what do we need?

  • First, a service provider with an API
  • Second, vRealize Orchestrator (vRO) will consume this API by creating a workflow
  • Third, vRA will turn this workflow into a service

To get through the technical stuff, it is expected you have basic understanding of what a REST API is and have a good knowledge of vRealize automation and vRO

Let’s go for the step by step:

The Service provider I chose is clickatell since they gave me immediately the API I needed. It costs me 20€ for 400 credits which translate into several hundred SMS (much more than I need here).

You’ll need to create an account and get to this page where you’ll find all the information you need.

  • The URL for your request
  • The JSON (or XML) structure
  • Your Auth token
How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

(optional) To get up to speed with this API, you can play with Postman       

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Open your vRO and add a REST host. Select Host Authentication type = OAuth2 and enter your token key

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Now, add a REST Operation

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Great, you now have linked vRO with your service provider

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Now, we are going to create a workflow to avoid doing these steps each time. Right click on the sendSMS operation/Run Workflow/Genereate a new workflow from the REST operation

 

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Automagically, vRO has created the workflow for you (this is really great stuff).

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

All you need is to add your Auth token your service provider gave you earlier.

 
//Customize the request here
request.setHeader("X-Version", "1");
request.setHeader("Content-Type", "application\/json");
request.setHeader("Authorization", "bearer xxxxxxxxxxxxxxxxxxxxxxxx");

 

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

You can now start your workflow and start sending SMS

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation
How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Great, it's working. Now, let's clean things a little bit.

 

Customize the code to make the input more user friendly, create 2 inputs.

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

And use it in your code:

 
//create the content
content="{\"text\":\"" +message +"\",\"to\":[\""+phonenumber +"\"]}";
System.log("Content: " + content
How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

That’s it you now have a user friendly workflow to send text messages from vRO

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Pretty cool right?

Now, how do we turn this workflow into a service?

Use the vRealize Automation magic:

In vRA, go to Design/XaaS Blueprints/New, pick your workflow, set the form as you want it, publish the service and entitle it.

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Voila

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Pretty neat right?

And that’s not all, you can actually turn this workflow into a service in different ways.

For example, in the vRA designer as “XaaS service”

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

Or leave the users enter their phone number at the request step.

How  to create and Advanced service (XaaS) to send SMS with vRealize Automation

 

I hope you found this interesting.

Let me know and feel free to share this post.