Many of our customers have asked about building URL links using variables collected during a decision tree session. This article shows how to do it.
In this how-to, we’ll explore:
- Using the string catenation webhook to build a URL variable from another variable.
- Substituting a variable into a link.
As an example, we’ll use a two-node tree. The first node collects a search term, and the second one creates a link to Google with the search term in the URL.
Building the Tree
- Set up the string catenation app. From Account, My Apps, create a webhook with this URL:
This article has more details.
- Create Node #1 with a data input field for the search term. Like so:
- Create Node #2, with a placeholder for the URL. Using the editor’s Code View tool, it looks like this:
We will be replacing the href=”#” part with the contents of a variable named url. Note the id=”URL” part of the code – that’s how the URL variable gets inserted into the href link.
- Go to the Apps/Webhooks part of Node #2, and add the String Catenator webhook from step 1. Like so:
- For the Message Data in the String catenator app, it will look like this:
- The string catenator app lets you combine variables with other text or variables to make a new variable. We will be creating a variable named url, which is a combination of:
and the search term, which is the variable named search.
- Here’s one technical quick: The first part of the url variable needs to be URL Encoded. This allows it to be passed to the webhook. We use this tool to transform this:
into a URL Encoded version:
- So the string catenator creates the variable URL, which combines https://google.com/search?q= with #search# – the search variable entered in Node #1.
- Finally, add button in Node #1 to go to Node #2.
And that’s it!