Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

asifnoor
Kilo Patron

Hi

In this article, I will show how to integrate with 3rd party API using Flow Designer. To explain this, i have taken 1 small requirement.

Requirement: Currency conversion. Create a catalog item where the user submit a request selecting the target currencies and base currency. 

For this, we create a flow designer which looks something like this.

find_real_file.png

 

As you can see the Flow is created on Request table. Then fetched the latest RITm for the request and filtered by our catalog item.

To fetch the values submitted in the request, you need to use Get Catalog variables action in Flow designer.

This will allow you to select the variables of your catalog item which you can use in your Flow. So in our case, we select base currency and target currencies here.

find_real_file.png

Once we have selected these, then we will pass these values to our action called Get Rates.

I have created a custom Action named Get Rates.

In Flow Designer -> You will see Actions tab. Go to actions tab and from there you can create action.

So our Get Rates action will look like this.

find_real_file.png

Click on Get Rates, it will open our action, which looks like this.

find_real_file.png

In this action i have created 3 input variables.

Access key: the key of our 3rd party API

symbols: refers to target currencies

base: refers to base currency

The data for these 3 variables are passed to this action from our flow designer.

find_real_file.png

Once the inputs are given to the action, then in the action we create REST STep and give the details like this.

In this step we are basically building a request and calling it.

find_real_file.png

find_real_file.png

Once this is done, then we need to capture the response of the API. For this, I have created a Script Step where we capture the response and pass it back to our flow designer.

find_real_file.png

 

Then in the script we actually parse the output and store it in a variable.

find_real_file.png

The create output variable where we can store the output of this script step.

find_real_file.png

Now the result_str contains the output of the script step, which is basically a parsed response from 3rd party API.

Then go to outputs section of our Action and there you capture this script step output like below.

 

find_real_file.png

So once we got the output, then we are taking this output and updating the work notes of the RITM as below.

find_real_file.png

That's it. We are done. It is very simple requirement but this should give you an idea on how to fetch the variables values from RITM in the flow designer, pass to the action call REST API, parse the API response and update the RITM.

Let me know if you have any questions in the comments below.

Mark the article as helpful and bookmark if you found it useful.


Regards,
Asif
2020 ServiceNow Community MVP

 

 

Version history
Last update:
‎01-05-2021 03:55 AM
Updated by: