Condition Jump Logic interfering with API calls?

I’m back on track building my complicated fee calculator, and as I worked through it, I found that it saved me a ton of extra work by adding conditional jump logic in the API calls (when applicable) to filter the the user to specific gambits based on previous choices. At first everything seemed to be working great, and then my round function through math.js stopped working. If I plug in a number that was generated through an equation exactly and test in the gambit console, it works, but when I reference the previous API calls total (exactly the same in this case) it fails to round and goes way wonky. The browser console reveals no errors while this is happening as well.

I had other instances too where a gambit would “spin” indefinitely, but once I removed the conditional jump logic, it would function. I know that it could easily have been user error, but the exact same conditional jump logic duplicated without an API call functions flawlessly. Maybe I’m just pushing the system too hard in what I’m asking it to do? I’m this close to making it work (it does work technically, but it seems pretty buggy). Any thoughts @vinit?

Hi @Levi,

Will have to check the Config in the Bot directly to see what’s the issue.
From the sound of it, it looks like that the param being sent to the math.js API is in string format, instead of a number.

So “23”, instead of 23
Which might be causing the issue.

Again need to check the API and the exact configuration to say for sure.

1 Like

So here are my three API calls. They happen in order. This has to be where the issue is.
“expr”: “{{ursp.MSRP}}*{{pre.fetch.table.rows[0].c[1].v}}*0.005”

“expr”: “round({{pre.retention1.result}},2)”
“expr”: “{{pre.calc1.result}}+217+10+10+10+6+7.59+{{}}”
I tested this treating it like a string and that fails to calculate the round function altogether. If I check the result of the second equation it is technically working and rounding, but then the result from the final gambit doesn’t. There are no other numbers entered (after the first equation) to create a repeating decimal. It’s a really strange case. Maybe it’s a bug with Math.js, but it’s such a simple calculation, I can’t imagine what the problem could be.

Note: the last equation is written out the way it is because I’m going to refer to a uval I have yet to build where the user selects their options and it either adds the numbers above or replace them with 0. So those will change to {{uval.option1}}+{{uval.option2}} etc.

The only thing I can find that may be causing this (though it still doesn’t make any sense) is when the round function goes to the second decimal, in cases it rounds to a 0, math.js drops the zero and returns a number to the tenth instead of the hundredth. When this is added to a number with a value in the hundredth, it causes the repeating decimal. In one test case this is 327.29000000001 and the equation is only adding 66.7+260.59 from everything I can verify. If I preform the ceil function and round the 66.7 up to 67 then add it together, there is not a problem (but it can have a variation of $.99 to $.01 difference from what the exact price is supposed to be). SO weird.

This is the bot:
You must select Gallatin > Passenger car > 2015 > 23000 and hit “Calculate!” to repeat this test. Right now I have ceil running instead of round, because my head hurts trying to fight with this thing. I need a precision attribute, but any attempts to replicate the function from math.js documentation has also been a bust :sob:

So I finally get a solution, which was a technically error because I’m a novice in JSON, but the API call is failing for another reason. If I plug in the hard numbers that are calculated, everything works fine. If I replace those hard numbers with my reference to a previous API call value, it fails. If I leave the reference in, but change the mathjs function from format to ceil, it works… I am so confused about this. Now, it literally doesn’t make any sense. Here’s what I’m getting when it fails:
It appears to me that pre.retention2.result is not populating with the value from the previous API call. But switching up the function somehow pulls the value in and it works. How is that even possible @vinit or is the error indicating something else is wrong?

1 Like


This error usually measn that there is something wrong in referencing the data.
Please check all the names of the gambit for same capitalization, no spaces, avoid using numbers in the gambit name.

It is currently very difficult for me to debug this, as the bot you are working on is very complex.
If you can make another small dummy bot, which recreates this issue then I can debug it a bit easily and quickly.

1 Like

Awesome! I’ll try removing the number out of the gambit name first to see if that takes care of the issue. If not, I have a sandbox bot that I will recreate this small part on and post the link here. Forgive all the posts, I was mostly trying to document and work through what I was having trouble with, whether or not someone else will ever need it is questionable, but you never know!

1 Like