You can use a structured output node to provide JSON schema to validate the output from the AI. Then, you need to explain in the system prompt very specifically the structure which you require and test around until it starts to return it.
In the MongoDB node, you can also try disabling the button and use this instead (replace the values):
{{$fromAI('fieldName', 'description', 'type')}}
This will allow you to also test another way of getting the string to JSON:
If i use the structured output node then before storing it in to DB then i canât use the ai tool feature. I also try that as well in that case i used mutiple ai aget node that i want to avoid.
Now, as you mentioned to change the âFieldâ option in the tool try disabling the button. I also tried that as well. On customizing the Fields , the input values given by ai agent also changing like :
error by agent : Tool call validation failed: tool call validation failed: parameters for tool Insert_in_DB did not match schema: errors: [additionalProperties âfull_nameâ, âcontactâ, ârequestedStartâ, ârequestedEndâ, âdescriptionâ not allowed]
This is the main flow with all the details without please add your credentials while testing
I tested it with the structured output parser and it works very well. Sorry I couldnât understand why you wanted to skip it - you mentioned you canât use the tool? Can you clarify what happens?
By using output parser i also tried i is working fine. But i want to use the tool itself.
In case of output parser some more nodes that are required extra in the flow , that i want to avoid.
Finally I got the solution.
The tool description should be
Insert an object in database. Send with the different json just with the values of the
{{ $fromAI('full_name', `Name of the customer`, 'string') }},
{{ $fromAI('contact', `Customer's contact`, 'string') }},
{{ $fromAI('description', `Appointment description`, 'string') }},
{{ $fromAI('start_appointment_time', `Start time of the appointment (ISO datetime)`, 'string') }},
{{ $fromAI('end_appointment_time', `End time of the appointment (ISO datetime)`, 'string') }}
and the Fields should be like exact key values: full_name,contact,description,start_appointment_time,end_appointment_time