If you’re using Data Entry Fields or Merge Variables to bring data into your decision tree session, you may want to perform basic math operations on these variables. Zingtree offers a stock webhook option that lets you assign a new variable to the results of an addition, subtraction, multiplication or division operation. Here’s how to set it up:
- Edit the node where you want the new variable (the result of the math operation) to be calculated.
- Click on the Apps/Webhooks tab.
- Under Call App or Webhook, choose Webhook: Zingtree Math.
- In the Message Data, you’ll need to provide the operation, the two variables or values to calculate, and a variable name for the result. In the example above, we’re assigning a variable named result to the sum of variables a and b. Variables must be enclosed in # characters.
Here are some message examples:
Sets variable c to 5+3
Sets variable net to the difference of variables gross and expenses.
Sets variable days = weeks * 7.
Sets variable weeks = days / 7.
You can use the following in the op= parameter:
The Zingtree Demo gallery has an example. You can try it and examine it.