NEW For more powerful tools consider the new Zingtree CX Actions: Transformation Functions and Script Node instead.
Overview
Zingtree provides a simple Webhook for taking numeric input, and converting it to a nicely formatted currency value. Like in these examples:
- 1234567 -> $1,234,567
- 123456 -> $123,456
- 123.00 -> $123
- 123.45 -> $123.45
Setup
In this example, we'll assume your tree has a variable named amount, and you want to convert it to a variable called dollars that displays nicely.
First of all, create a webhook to call the currency converter.
-
From the Apps & Integrations menu, choose My Apps:
This page lists all of the Apps you have presently installed. You can edit, duplicate, or delete any of them from the list. In the Uses column, you can easily see how many trees an individual App is being used. Click on the number in the Uses column to see which trees are using that App.
Adding a new App
Click the Install App button. You'll then see this screen:
Choose the Webhook button to add a new Webhook.
- Give the webhook a name, and enter this into the URL:
https://webhooks.zingtree.com/zingtree/v1/make_currency
It will look like this: - Save Settings
Next, go into your tree, and add the webhook to a node after the amount variable has been set.
- Edit the node, and click Apps/Webhooks
- Pick the new Webhook you created from the list. Ours is called "Currency Formatter".
- Add these parameters to the message data:
&value=#amount#&return=dollars
It looks like this: - Now insert #dollars# into the content area to display the result.
Parameter Reference
In the Message Data, you can include these parameters:
- value= (the numeric value to convert)
- return= (the variable that gets the formatted currency)
- currency= (The currency, i.e. USD, EUR, etc.) USD is the default.
- locale= (How to format the number returned by region.) Default is USA (en_US). German would be de_DE, etc.