Tour Guide

On this page:

Custom Values

Customizing Values

In this section, we'll introduce the newVariable task and utilize the replace task to customize the API's URL so that we can receive a slightly different output.

Note: This section uses the Gen1 Automation Builder canvas.

Get Prepared to Pass Variables

With the test API we've been using, you can have some additional fun by injecting your own name within the Chuck Norris facts. Fortunately, the test API we've been using will allow us to demonstrate this, but first, we'll need to set-up some more tasks to handle the additional information.

There are a few ways to do this, but for purposes of this guide, we'll stick with a simple method that uses a few replace tasks and newVariable tasks to illustrate how variables are passed within an automation. As you become more comfortable with the capabilities of IAP and other various tasks, you may discover another more efficient method to accomplish the same goal.

Add More Tasks to an Automation

From the Task Menu Sidebar, add the following:

  • Three (3) newVariable tasks
  • Two (2) replace tasks

Warning: At this point in your automation build, you'll discover that you need to rearrange the additional tasks on the canvas to ensure they are all clearly visible. Just click/hold and drag them to their desired location. Depending on the size of your monitor and how visually organized you are, the process of rearranging the various tasks on a canvas may (surprisingly) take some extra time.

Build the API URI

The Chuck Norris API will accept the following format and return a customized name within the fact.

http://api.icndb.com/jokes/random?firstName={firstname}&lastName={lastName}
  1. Click to open one of the newVariable tasks you just added.
  2. Provide FactURL as the New Variable Name.
  3. Provide this value (without quotes): http://api.icndb.com/jokes/random?firstName=customfirstname&lastName=customlastname.
  4. Save the task.

This newVariable will be used as a template for the API URI we'll submit later on. If you were to submit it now "as is", it would be rather boring, so let's continue.

Build the Custom Name Variables

From the sample URI template above, you'll see that you can add a firstname and lastname to the API.

  1. Click to open one of the remaining newVariable tasks you added.
  2. Provide MyFirstName as the New Variable Name.
  3. Provide the value (without quotes) of whatever Firstname would amuse you.
  4. Save the task.
  5. Click to open the third and final newVariable task.
  6. Provide MyLastName as the New Variable Name.
  7. Provide the value (without quotes) of whatever Lastname would amuse you.
  8. Save the task.

Start Connecting Tasks

Next, you'll connect all the tasks:

  1. Delete the transition between START and the FetchFact task.
  2. Add a transition from START to the FactURL task.
  3. Add a transition from FactURL to the MyFirstName task.
  4. Add a transition from MyFirstName to the MyLastName task.
  5. Add a transition from MyLastName to one of the replace tasks you added earlier.

Configure the Replace Tasks

The replace tasks will help you swap out the generic customfirstname and customlastname phrases in the URL value of our FactURL task with something more interesting.

  1. Click to open the replace task you connected in the previous section.

  2. Change the Summary to "FirstName-Update".

  3. For the str variable:

    • Change the Reference task to New Variable: FactURL.
    • Keep the default value for the Reference variable.
  4. For the substr variable:

    • Keep the Reference task setting as static.
    • Change the Reference variable to (without quotes) customfirstname.

    You will probably recognize this value (phrase) from the URL that was provided for the FactURL task.

  5. For the newSubstr variable:

    • Change the Reference task to New Variable: MyFirstName.
    • Keep the default value for the Reference variable.
  6. Save the task.

  7. Add a transition from the "FirstName-Update" task to the other replace task you previously created.

  8. Click to open the second replace task.

  9. Change the Summary to "LastName-Update".

  10. For the str variable:

    • Change the Reference task to FirstName-Update.
    • Keep the default value for the Reference variable.
  11. For the substr variable:

    • Keep the Reference task setting as static.
    • Change the Reference variable to (without quotes) customlastname.

    Again, you will probably recognize this value (phrase) from the URL that was provided for the FactURL task.

  12. For the newSubstr variable:

    • Change the Reference task to New Variable: MyLastName.
    • Keep the default value for the Reference variable.
  13. Save the task.

As a checkpoint, let's review what you've done so far:

  • Created a URL template ("FactURL").
  • Created new (placeholder) variables for the First and Last name values (MyFirstName and MyLastName, respectively).
  • Created two tasks that sequentially take the FactURL template and swap out firstName and lastName information into the appropriate spots within the URL.

Now all you need to do is provide the updated URL to the RestCall itself.

Finish Connecting & Configuring Tasks

Complete these last few steps to connect and configure all your tasks:

  1. Add a transition from the LastName-Update task to the FetchFact task.
  2. Click to open the FetchFact task.
  3. Change the uri variable:
    • Change the Reference task to LastName-Update.
    • Keep the default replacedString value for the Reference variable.
  4. Save the task.

You should now have an automation with nine (9) connected tasks in the following order:

  1. START
  2. FactURL
  3. MyFirstName
  4. MyLastName
  5. FirstName-Update
  6. LastName-Update
  7. FetchFact
  8. Query (IsolateFact)
  9. END

Figure 1. Connected Tasks

13-EnlightenMe

Run the Automation

After running the automation, go to the IsolateFact (Query) Task History within Job Manager. You should find that instead of "Chuck Norris", the joke now uses your custom name.

Figure 2. Custom Name Value

14-EnlightenMe

Summary Wrap-Up

A job well done! You've learned how to create a URL template, customize values in your sample API, and build a more complex automation using the replace and newVariable tasks.

In the next section, you'll create a user input form that allows you to reuse the custom name automation you just built.