 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:

1. Edit the node where you want the new variable (the result of the math operation) to be calculated.
2. Click on the Apps/Webhooks tab.
3. Under Call App or Webhook, choose Webhook: Zingtree Math. 4. 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.

### Example Calculations

Here are some message examples:

&op=plus&a=5&b=3&result=c
Sets variable c to 5+3

&op=minus&a=#gross#&b=#expenses#&result=net
Sets variable net to the difference of variables gross and expenses.

&op=times&a=#weeks#&b=7&result=days
Sets variable days = weeks * 7.

&op=div&a=#days#&b=7&result=weeks
Sets variable weeks = days / 7.

### Operations Reference

You can use the following in the op= parameter:

• plus
• minus
• times
• div

### Demo

The Zingtree Demo gallery has an example. You can try it and examine it.