Engati - User Guide
...
3. Path Setup
Mongo DB Path Setup
11 min
this section explains how to configure a mongo retrieval path after the custom script data is stored in the database followed by the step by step setup step 1 — create a new path go to the builder section click + add path and create a new path example path name mongo search path step 2 — add a json api node inside the path, click add node and select json api this node will be used to fetch stored mongo data step 3 — configure the json api request set the request method to post in the request url field, enter the mongo api endpoint url \<https //mongo fetch> go to the body tab and set content type as json use the following request body { "bot ref" "{{bot id}}", "fields to fetch" \[ "doctor name", //retreival fields "experience" ], "filters" \[ { "speciality" "{{speciality}}" } ], "database" "customer data", "collection name" "{{bot id}}" } this request retrieves data by matching the exact field value passed in user query request body explanation field description bot ref unique identifier of the bot this ensures the request fetches data specific to that bot fields to fetch specifies which fields should be returned from the database only the listed fields will be retrieved filters used to search for records matching specific field values stored in the database database name of the mongo database where the data is stored collection name mongo collection where the records are stored in this case it uses the bot id example if user query = cardiology, the api will return the doctor record where speciality = cardiology speciality step 4 — test the api request click send request to test the api the system will prompt you to enter test values for bot id speciality enter sample values and submit the request example bot id → 145265 speciality → cardiology where to find bot id? bot id (bot id) – found in the builder url (last number in the url) example 145265 once the request is successful, the api response will appear in the response section example response { "response" \[ { "doctor name" "dr arjun mehta", "experience" "15 years", " id" "69b3bf53e69521c8608e1dd" } ] } this means the system found a matching record from the stored mongo data step 6 — map the response to attributes in the attributes section, create attributes to store the response you can store the full response or individual fields example mappings response or specific values doctor name response 0 doctor name experience response 0 experience this stores the returned mongo values in attributes for later use in the path step 7 — save the node after testing the request and mapping the response, click save the json api node is now ready to retrieve mongo data during conversations how retrieval works data is first stored in mongodb through the custom script the json api node sends a filter request mongo searches for records matching the exact field value the matched result is returned in the api response the response is stored in attributes those attributes can be used in the next node to reply to the user example stored record { "doctor name" "dr arjun mehta", "speciality" "cardiology", "location" "bangalore", "experience" "15 years" } filter used in request { "speciality" "cardiology" } returned result dr arjun mehta 📚 next step once the mongo api response is stored in an attribute, you can use that attribute in the next node to send the retrieved answer back to the user 👉 continue to the next section docid\ uuhjizq8x 4pijssvst9q
