Pitfalls to avoid
The most frequent Dialplan error made by people new to FreeSWITCH (and by distracted old hands) is without any doubt setting a variable and expecting to be able to check it some lines down for the assigned value. NOOOOOOOOOOOT.
In this book, I am repeating the concept very (too much?) often, trying to leave a mark in your collective consciousness, but let's do it again here:
- Dialplan is first "traversed" by the call, checking all extensions, conditions, and so on for matches. Only after all the "traversing" is done and completed, are the actions in the TODO list executed.
- If there are condition matches, then actions will be put in the TODO list.
- Some of those actions can be "set" actions, actions that assign variables.
- So, we just added a variable setting action in the TODO list.
- We then check the variable. Is it STILL OLD (or nonexistent) VALUE.
- That's because we are still in the traversing phase, we have not yet executed the "set" action.
- Got it?
- If you want your "set" action...