Describe the problem/error/question
my ai agent is not formatting data into the JSON, and not updating the google sheet fields. i am collecting orders and reservations and updating in the google sheet
Please share your workflow
`{
"nodes": [
{
"parameters": {
"promptType": "define",
"text": "={{ $json.body.query }}",
"options": {
"systemMessage": "=You are an AI agent that processes customer food orders and reservations for a Mexican restaurant. After receiving structured data from a voice agent, your job is to extract and format fields for order or reservation, and send them to the appropriate Google Sheet.\n\nCurrent date {{ $now }}\n\n## Voice & Tone Guidelines\n- Speak like a friendly team member. Keep it relaxed and conversational.\n- Use natural phrases like: “Sure!”, “Got it!”, “Hmm, let me check…”\n- Confirm things clearly but casually: “Just to make sure, you said…”\n- Avoid sounding robotic. Be helpful, warm, and real.\n- Only mention ingredients if the customer asks.\n\n\n## Order Processing\n\n1. Extract and assign:\n - **Food_Items**\n - **Quantity**\n - **Special_Instructions**\n - **Delivery_Pickup**: Always “Pickup”\n - **Time**\n - **Customer_Name**\n - **Phone_Number**\n - **Status**\n\n2. Confirm the extracted details with the customer.\n3. ONCE THE CUSTOMER HAS CONFIRMED AND YOU HAVE ALL REQUIRED DETAILS, **USE THE `update_food_orders_sheet` TOOL.** Generate a unique timestamp-based Order ID (e.g., ORD-YYYYMMDD-HHMMSS) and provide all extracted order details to the tool in the required JSON format.\n\n## Reservation Processing\n\n1. Collect and map:\n - **Reservation_ID**\n - **Customer_Name**\n - **Contact_Number**\n - **Email**\n - **Reservation_Date**\n - **Reservation_Time**\n - **Number_of_Guests**\n - **Seating_Preference / Special_Requests**\n\n2. Confirm the extracted details with the customer.\n3. ONCE THE CUSTOMER HAS CONFIRMED AND YOU HAVE ALL REQUIRED DETAILS, **USE THE `update_reservations_sheet` TOOL.** Generate a unique Reservation ID and provide all extracted reservation details to the tool in the required JSON format.\n\n## JSON Input Format for Tools (VERY IMPORTANT)\n\nWhen calling the `update_food_orders_sheet` or `update_reservations_sheet` tool, you **MUST** provide the arguments as a valid JSON object matching the exact structure below.\n\n### For `update_food_orders_sheet` (Order):\n```json\n{\n \"Customer_Name__using_to_match_\": \"extracted_customer_name\",\n \"Order_ID\": \"generated_order_id\",\n \"Food_Items\": \"extracted_food_items\",\n \"Quantity\": \"extracted_quantity\",\n \"Special_Instructions\": \"extracted_special_instructions\",\n \"Time\": \"extracted_time\",\n \"Status\": \"Pending\",\n \"Delivery_Pickup\": \"Pickup\",\n \"Phone_Number\": \"extracted_phone_number\"\n}\nFor update_reservations_sheet (Reservation):\nJSON\n\n{\n \"Reservation_ID\": \"generated_reservation_id\",\n \"Customer_Name\": \"extracted_customer_name\",\n \"Contact_Number\": \"extracted_contact_number\",\n \"Email\": \"extracted_email\",\n \"Reservation_Date\": \"extracted_reservation_date\",\n \"Reservation_Time\": \"extracted_reservation_time\",\n \"Number_of_Guests\": \"extracted_number_of_guests\",\n \"Seating_Preference\": \"extracted_seating_preference\",\n \"Special_Requests\": \"extracted_special_requests\"\n}\nFinal Notes\nPlease just go ahead and extract only what is clearly provided.\nValidate all required fields before proceeding.\nAlways use the provided Google Sheets tools for output.\nAvoid unnecessary tokens for speed.\nIf you have successfully used a tool, you can then respond to the user with a confirmation message.\nExamples\nOrder\nCustomer: “Three veggie burritos, one without sour cream, and fries. Pickup at 6:30.”\n→ Map Food_Items, Quantity, Special_Instructions, Time, Name, Phone.\nOnce confirmed, call update_food_orders_sheet with the order details.\n\nReservation\nCustomer: “Table for 2 tomorrow at 8 PM near the window.”\n→ Map Guest count, Date, Time, Seating Preference, Name, Phone, Email.\nOnce confirmed, call update_reservations_sheet with the reservation details.\n\nToday is {{ $json.today }}.\nWhen someone asks about today’s specials, only respond with the items under {{ $json.today }}.\n\nHere are the daily specials:\n\nMonday: Margarita Monday – House Rita $5, Domestic Craft $2.50, Supremo Burrito $16\nTuesday: Taco Tuesday – Mexican Taco $2.50, American Taco $1.99, House Sangria $6, Moscow Mule $7, Arroz Con Pollo $16, Carnitas De Pollo $16\nWednesday: Loco Wednesday – Super Chimichanga $15, Enchiladas $15, Mojitos $7, Skinny Rita $8\nThursday: Thirsty Thursday – Super Nachos $11, Chicken Fajitas $17, Cadillac Rita $9, Jalapeño Cucumber Margarita $9, Raspberry Rita $8\nFriday–Sunday: No daily specials, just Happy Hour.\nHappy Hour (Every day 11am–7pm):\n\nHouse Sangria $6, House Rita $5, House Wine $6, Domestic Beer $2.50\nTools\nOpenAI Chat Model (for conversation)\nupdate_food_orders_sheet (Tool for updating food orders in Google Sheets)\nupdate_reservations_sheet (Tool for updating reservations in Google Sheets)"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.8,
"position": [
440,
0
],
"id": "259a3df9-5063-47f1-b336-b60528c89cf4",
"name": "Restaurant AI Agent"
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "12VJO6Cbum6bTtnu6J-V_m0zIb3uVArWQpK24s9em6jg",
"mode": "list",
"cachedResultName": "Confirmed Reservations Takos Cantina",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/12VJO6Cbum6bTtnu6J-V_m0zIb3uVArWQpK24s9em6jg/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/12VJO6Cbum6bTtnu6J-V_m0zIb3uVArWQpK24s9em6jg/edit#gid=0"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"Reservation ID"
],
"schema": [
{
"id": "Reservation ID",
"displayName": "Reservation ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Customer Name",
"displayName": "Customer Name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Contact Number",
"displayName": "Contact Number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Email",
"displayName": "Email",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Reservation Date",
"displayName": "Reservation Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Reservation Time",
"displayName": "Reservation Time",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Number of Guests",
"displayName": "Number of Guests",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Seating Preference",
"displayName": "Seating Preference",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Special Requests",
"displayName": "Special Requests",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Confirmed by (Staff Name/AI)",
"displayName": "Confirmed by (Staff Name/AI)",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Confirmation Timestamp",
"displayName": "Confirmation Timestamp",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
0,
500
],
"id": "d9130fe9-d6d3-48be-adc0-23288c138f4a",
"name": "Get Confirmed Reservation",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "9F1NALsPOKCXZMRy",
"name": "Inca Media Google Sheet"
}
}
},
{
"parameters": {
"content": "## Handling Orders\n",
"height": 280,
"width": 360,
"color": 4
},
"type": "n8n-nodes-base.stickyNote",
"position": [
660,
400
],
"typeVersion": 1,
"id": "ec946897-bb99-45d7-8014-43570e2d76da",
"name": "Sticky Note"
},
{
"parameters": {
"content": "## Handling Reservations\n",
"height": 280,
"width": 500,
"color": 3
},
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
400
],
"typeVersion": 1,
"id": "edc83ac4-4e40-4057-803f-bee9df71b27f",
"name": "Sticky Note1"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "gpt-4o-mini",
"mode": "list",
"cachedResultName": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
120,
200
],
"id": "76b148ed-4e32-4281-996f-d530f35ccf2b",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"id": "UtTsTkoVcGBRfhwk",
"name": "OpenAi account"
}
}
},
{
"parameters": {
"httpMethod": "POST",
"path": "a61b668e-7c90-487a-92ee-06b9a8aee334",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
0
],
"id": "663ed267-5abf-41cd-bbf3-97e6f4fa365e",
"name": "Webhook",
"webhookId": "a61b668e-7c90-487a-92ee-06b9a8aee334"
},
{
"parameters": {
"sessionIdType": "customKey",
"sessionKey": "={{ $('Webhook') }}"
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
480,
320
],
"id": "08f6fcc5-b7f8-4a70-bd1f-ba76b27dcbbb",
"name": "Simple Memory"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.3,
"position": [
1040,
0
],
"id": "ad7f29fa-32ea-4a16-bcaf-7b1444662bb2",
"name": "Respond to Webhook"
},
{
"parameters": {
"jsCode": "const date = new Date();\nconst weekdays = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"];\n\nitems[0].json.today = weekdays[date.getDay()];\n\nreturn items;\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
220,
0
],
"id": "d8a378af-774c-4dd4-a262-1458803d4ab5",
"name": "Set Today"
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "1ibdPgGeTUqVOx5jcuCG6V3qriA_KZXMnmXjtB7fWkMg",
"mode": "list",
"cachedResultName": "Orders Takos Cantina",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ibdPgGeTUqVOx5jcuCG6V3qriA_KZXMnmXjtB7fWkMg/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ibdPgGeTUqVOx5jcuCG6V3qriA_KZXMnmXjtB7fWkMg/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Customer Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Customer_Name__using_to_match_', ``, 'string') }}",
"Order ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Order_ID', ``, 'string') }}",
"Food Items": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Food_Items', ``, 'string') }}",
"Quantity": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Quantity', ``, 'string') }}",
"Special Instructions": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Special_Instructions', ``, 'string') }}",
"Time": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Time', ``, 'string') }}",
"Status": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Status', ``, 'string') }}",
"Delivery/Pickup": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Delivery_Pickup', ``, 'string') }}",
"Phone Number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Phone_Number', ``, 'string') }}"
},
"matchingColumns": [
"Order ID"
],
"schema": [
{
"id": "Order ID",
"displayName": "Order ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Customer Name",
"displayName": "Customer Name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Phone Number",
"displayName": "Phone Number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Food Items",
"displayName": "Food Items",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Quantity",
"displayName": "Quantity",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Special Instructions",
"displayName": "Special Instructions",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Delivery/Pickup",
"displayName": "Delivery/Pickup",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Time",
"displayName": "Time",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
800,
500
],
"id": "30f4618d-3f93-4b4e-a521-ca706295cfa1",
"name": "update_food_orders_sheet",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "9F1NALsPOKCXZMRy",
"name": "Inca Media Google Sheet"
}
},
"notes": "Use this tool to add or update customer food orders in the 'Orders Takos Cantina' Google Sheet. Provide all extracted order details in JSON format, including Customer_Name, Order_ID, Food_Items, Quantity, Special_Instructions, Time, Status, Delivery_Pickup, and Phone_Number. Always use this tool when an order is confirmed."
},
{
"parameters": {
"operation": "appendOrUpdate",
"documentId": {
"__rl": true,
"value": "12VJO6Cbum6bTtnu6J-V_m0zIb3uVArWQpK24s9em6jg",
"mode": "list",
"cachedResultName": "Confirmed Reservations Takos Cantina",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/12VJO6Cbum6bTtnu6J-V_m0zIb3uVArWQpK24s9em6jg/edit?usp=drivesdk"
},
"sheetName": {
"__rl": true,
"value": "gid=0",
"mode": "list",
"cachedResultName": "Sheet1",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zbTEErfePt6nfrqML9Ko6kYzbrkkytq6cfbuVYZKVC8/edit#gid=0"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Customer Name": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Customer_Name__using_to_match_', ``, 'string') }}",
"Reservation ID": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Reservation_ID', ``, 'string') }}",
"Contact Number": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Contact_Number', ``, 'string') }}",
"Email": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Email', ``, 'string') }}",
"Reservation Date": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Reservation_Date', ``, 'string') }}",
"Reservation Time": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Reservation_Time', ``, 'string') }}",
"Number of Guests": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Number_of_Guests', ``, 'string') }}",
"Seating Preference": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Seating_Preference', ``, 'string') }}",
"Special Requests": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Special_Requests', ``, 'string') }}",
"Confirmation Timestamp": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Confirmation_Timestamp', ``, 'string') }}",
"Confirmed by (Staff Name/AI)": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Confirmed_by__Staff_Name_AI_', ``, 'string') }}"
},
"matchingColumns": [
"Reservation ID"
],
"schema": [
{
"id": "Reservation ID",
"displayName": "Reservation ID",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Customer Name",
"displayName": "Customer Name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Contact Number",
"displayName": "Contact Number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Email",
"displayName": "Email",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Reservation Date",
"displayName": "Reservation Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Reservation Time",
"displayName": "Reservation Time",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Number of Guests",
"displayName": "Number of Guests",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Seating Preference",
"displayName": "Seating Preference",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Special Requests",
"displayName": "Special Requests",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Confirmed by (Staff Name/AI)",
"displayName": "Confirmed by (Staff Name/AI)",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Confirmation Timestamp",
"displayName": "Confirmation Timestamp",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheetsTool",
"typeVersion": 4.5,
"position": [
200,
500
],
"id": "070ec17b-ecf6-43a1-a28b-1c18e17fb910",
"name": "update_reservations_sheet",
"credentials": {
"googleSheetsOAuth2Api": {
"id": "9F1NALsPOKCXZMRy",
"name": "Inca Media Google Sheet"
}
},
"notes": "Use this tool to add or update customer table reservations in the 'Confirmed Reservations Takos Cantina' Google Sheet. Provide all extracted reservation details in JSON format, including Reservation_ID, Customer_Name, Contact_Number, Email, Reservation_Date, Reservation_Time, Number_of_Guests, Seating_Preference, and Special_Requests. Always use this tool when a reservation is confirmed."
},
{
"parameters": {
"jsCode": "return [\n {\n json: {\n debug: JSON.stringify($json, null, 2)\n }\n }\n];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
800,
0
],
"id": "6372f3e5-8ada-4631-83b3-76ad83f4288e",
"name": "Code"
}
],
"connections": {
"Restaurant AI Agent": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Get Confirmed Reservation": {
"ai_tool": [
[
{
"node": "Restaurant AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Restaurant AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Webhook": {
"main": [
[
{
"node": "Set Today",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Restaurant AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Respond to Webhook": {
"main": [
[],
[]
]
},
"Set Today": {
"main": [
[
{
"node": "Restaurant AI Agent",
"type": "main",
"index": 0
}
]
]
},
"update_food_orders_sheet": {
"ai_tool": [
[
{
"node": "Restaurant AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"update_reservations_sheet": {
"ai_tool": [
[
{
"node": "Restaurant AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"pinData": {},
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "5e3f46581004d249d6be9fd76f13b7815e3f86060e1cf7c22cee0cce22cff48d"
}
}`
Share the output returned by the last node
[
{
“output”: “Just to confirm, you’d like to place an order for William for one Macho Burrito with chicken, for pickup in 45 minutes. The phone number provided is 720-331-7740. \n\nShall I go ahead and place this order?”
}
]
Information on your n8n setup
- n8n version: 1.98.2
- Database (default: SQLite): dont know
- n8n EXECUTIONS_PROCESS setting (default: own, main): self hosted
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker
- Operating system: hostinger vps