Compute
A Compute step calculates a figure from a formula and stores it, with the rounding you choose. Use it for anything a customer could be quoted, so the number is the same every time and can be checked.
When to use it
Section titled “When to use it”- Work out a loan EMI from the amount, rate and tenure.
- Calculate a renewal premium with a no-claim bonus.
- Add up an order total with tax and delivery charges.
When not to use it
Section titled “When not to use it”- You only need to copy or rename values. Use Data mapper.
- The result picks a path rather than a number. Use Condition or Decision (rules).
Settings
Section titled “Settings”| Setting | What it does |
|---|---|
| Formula | Required. An expression, for example p * r * (1 + r) ** n / ((1 + r) ** n - 1). |
| Store result as | Required. The name of the result, stored at data.<name>. |
| Decimal places | 0 to 10. Empty keeps full precision. Use 2 for money. With 0 the result is a whole number. |
| Rounding | When decimal places are set. half_up (default), half_even, down (towards zero) or up (towards the higher number). |
| More results | Further name and formula pairs. They can use the main result by its name, and earlier entries by theirs. Rounding applies to them too. A further result cannot reuse the main result’s name. |
What it produces
Section titled “What it produces”- A single Next.
data.<name>for the main result and for each further result.
A formula that cannot be worked out, such as a division by zero, fails the run, as this step has no error path.
Example
Section titled “Example”A lender quotes an EMI on a call.
Conversational agent (collect amount and tenure) → Compute (emi) → Send message (EMI quote) → End- Formula:
p * r * (1 + r) ** n / ((1 + r) ** n - 1), using a Data mapper earlier that setp=input.amount,r=input.annualRate / 12 / 100,n=input.months. - Store result as:
emi. Decimal places: 2. - More results:
totalPayable=emi * n.
{ "p": 500000, "r": 0.0091667, "n": 36, "emi": 16369.36, "totalPayable": 589296.96 }