Odoo request
Queries your Odoo during the call and stores the response in variables: an order status, a balance, an appointment date, to route accordingly.
In brief
| Outputs | OK and Error |
| Fields | Odoo instance, Timeout, Model, Method, Args (JSON), Kwargs (JSON), and an extraction array of Variable and JSON path |
| Timeout offered | 2, 3, 5 or 8 s, 5 s by default |
| Timeout actually applied | 8 seconds maximum |
| Method suggested on creation | search_read |
| Circuit breaker | 5 consecutive failures on the same server open the circuit for 30 seconds |
| Trial before going live | Test button, which actually queries your Odoo |
The help text shown in the window is: "Calls execute_kw(model, method, args, kwargs) on Odoo. args/kwargs = JSON with {{variables}} ({{caller_e164}} = E.164 forms of the caller). Extracts the JSON response into variables. 'Error' output if Odoo fails/times out."
How it works
This is the most technical module of the set. Where Odoo, contact resolution answers a single, ready-made question, this one asks any question of your Odoo. In exchange, you need to know where the information lives in Odoo.
The four fields of the question
| Field | What it is | Example |
|---|---|---|
| Model | the internal name of the Odoo table being queried | res.partner for contacts |
| Method | what you're asking of that table | search_read to search then read |
| Args (JSON) | the arguments, in practice the search filter | [[["phone_sanitized","in","{{caller_e164}}"]]] |
| Kwargs (JSON) | the named options: which fields to read, how many rows | {"fields":["name","user_id"],"limit":1} |
The model's name is read in Odoo, by enabling developer mode, or asked of the person who administers your Odoo. It's the only part of this page you can't guess.
JSON, in one sentence
Args and Kwargs are written in JSON, a format where square brackets [ ] delimit a list, braces { } a set of named fields, and where all text is between straight quotes. One missing comma or an unclosed brace is enough to make the request fail.
Variables in the question
Write {{my_variable}} anywhere in Args or Kwargs. A useful nuance: a variable wrapped in quotes, like "{{caller_e164}}", is replaced by its value in JSON form, quotes included. A list therefore stays a list, which lets you write a filter of the type "the phone is among these forms."
Extraction
The table at the bottom links a JSON path to a Variable name. Levels are separated by dots; lists are counted from zero. search_read responds with a list, so the path to a first result starts with 0.: 0.name refers to the name of the first contact found.
A path left blank returns the entire response. This is essential for methods that respond with a number or a word with no structure around it, such as a count: without this, the variable would stay empty and any condition testing it would always be false.
The circuit breaker
As with the API request, after 5 consecutive failures toward the same server, the module stops calling it for 30 seconds and takes the Error output immediately, without any request. A first success resets the counter to zero.
What to fill in
| Field | What is expected | If you leave it empty |
|---|---|---|
| Odoo instance | the Odoo to query, among those declared in Integrations, Odoo | Default instance, the resolution instance declared for your installation |
| Timeout | the wait delay, capped at 8 s maximum at run time | 5 s |
| Model | the Odoo model name, for example res.partner | the Error output is taken without any request being sent |
| Method | the method to call, pre-filled with search_read | the Error output is taken without any request being sent |
| Args (JSON) | the arguments, in valid JSON | empty list |
| Kwargs (JSON) | the named options, in valid JSON | no options |
| Variable of an extraction | the name to store the read value under | the row is ignored |
| JSON path of an extraction | the path to the value, for example 0.name | the entire response is stored in the variable |
The window's buttons are Add an extraction, Test, Cancel and Save.
Steps
- Check that your Odoo is connected, in Integrations, Odoo, and that the instance is active there.
- Identify in Odoo the model and the fields that carry the information you want. Get help from the person who administers your Odoo if needed.
- Place the Odoo request module and connect the previous node to its input.
- Open it, choose the Odoo instance and set the Timeout as short as possible: two to three seconds, the caller is waiting on the line.
- Enter the Model and the Method.
- Write the Args (JSON) and the Kwargs (JSON), limiting the number of rows read with
"limit":1when one is enough. - Click Add an extraction and pair a JSON path with a Variable name.
- Click Test, fill in the trial variables, then click Run. Fix things until the value obtained is correct.
- Click Save, then connect OK to the rest of the plan and Error to a fallback that handles the call without the data.
- Click Save, then Apply changes in the top banner.
- Call your number and check the routing, with the help of a Debugging module that writes the extracted variables.
If it doesn't work
The Error output is taken immediately, without any request being sent. Three causes. The Model or the Method is empty. The chosen Odoo instance no longer exists or is no longer active. Or the circuit breaker is open, after five consecutive failures, for thirty seconds.
The request fails even though the JSON looks correct to me. It must stay valid once the variables are replaced, and that's where most errors happen. Click Test: the screen shows the request actually sent, args and kwargs after replacement. For a variable to be replaced by its JSON value, wrap it in quotes: "{{caller_e164}}".
The extracted variable stays empty even though the response contains the data. The path doesn't match. search_read responds with a list: start with 0. for the first element. A method that responds with a single number, on the other hand, requires an empty path. The Value obtained column of the trial flags empty extractions.
The trial asks me to confirm before running. The requested method writes to Odoo instead of just reading. The trial actually runs against your production Odoo: only confirm if you accept that write.
The call cuts off when Odoo responds badly. The Error output is not connected to anything. This module does not have the contact resolution module's automatic fallback: connect Error, at minimum toward the usual greeting.
How the call flow is built, explained in pictures
See the Dial plans page