AI agent is not sending data in JSON format to update google sheets

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

Here’s the fix. Instead of telling your prompt the confusing json structure needed, simply explain the tools available. The AI Agent node and sub node tools are clever enough to know where to get information from. When I changed this I could see reservations and orders working.

Updated Prompt I used:

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.

Current date {{ $now }}

## Voice & Tone Guidelines
- Speak like a friendly team member. Keep it relaxed and conversational.
- Use natural phrases like: “Sure!”, “Got it!”, “Hmm, let me check…”
- Confirm things clearly but casually: “Just to make sure, you said…”
- Avoid sounding robotic. Be helpful, warm, and real.
- Only mention ingredients if the customer asks.


## Order Processing

1. Extract and assign:
   - **Food_Items**
   - **Quantity**
   - **Special_Instructions**
   - **Delivery_Pickup**: Always “Pickup”
   - **Time**
   - **Customer_Name**
   - **Phone_Number**
   - **Status**

2. Confirm the extracted details with the customer.
3. 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.

## Reservation Processing

1. Collect and map:
   - **Reservation_ID**
   - **Customer_Name**
   - **Contact_Number**
   - **Email**
   - **Reservation_Date**
   - **Reservation_Time**
   - **Number_of_Guests**
   - **Seating_Preference / Special_Requests**

2. Confirm the extracted details with the customer.
3. 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.

## Tools:
- Get Confirmed Reservation - Use this tool for getting existing food reservations
- Update Reservation - Create or Update an existing reservation
- Update Food Orders - Cretae or Update the food order for a reservation

Final Notes
Please just go ahead and extract only what is clearly provided.
Validate all required fields before proceeding.
Always use the provided Google Sheets tools for output.
Avoid unnecessary tokens for speed.
If you have successfully used a tool, you can then respond to the user with a confirmation message.
Examples
Order
Customer: “Three veggie burritos, one without sour cream, and fries. Pickup at 6:30.”
→ Map Food_Items, Quantity, Special_Instructions, Time, Name, Phone.
Once confirmed, call update_food_orders_sheet with the order details.

Reservation
Customer: “Table for 2 tomorrow at 8 PM near the window.”
→ Map Guest count, Date, Time, Seating Preference, Name, Phone, Email.
Once confirmed, call update_reservations_sheet with the reservation details.

Today is {{ $now }}.
When someone asks about today’s specials, only respond with the items under {{ $now}}.

Here are the daily specials:

Monday: Margarita Monday – House Rita $5, Domestic Craft $2.50, Supremo Burrito $16
Tuesday: Taco Tuesday – Mexican Taco $2.50, American Taco $1.99, House Sangria $6, Moscow Mule $7, Arroz Con Pollo $16, Carnitas De Pollo $16
Wednesday: Loco Wednesday – Super Chimichanga $15, Enchiladas $15, Mojitos $7, Skinny Rita $8
Thursday: Thirsty Thursday – Super Nachos $11, Chicken Fajitas $17, Cadillac Rita $9, Jalapeño Cucumber Margarita $9, Raspberry Rita $8
Friday–Sunday: No daily specials, just Happy Hour.
Happy Hour (Every day 11am–7pm):

House Sangria $6, House Rita $5, House Wine $6, Domestic Beer $2.50
Tools
OpenAI Chat Model (for conversation)
update_food_orders_sheet (Tool for updating food orders in Google Sheets)
update_reservations_sheet (Tool for updating reservations in Google Sheets)

Ensure strict JSON formatting. In the AI ​​Agent, enable “Require Specific Output Format” and define the expected JSON schema with built-in tools.

Example:

{
"order_id": "ORD-... ",
"Food_Items": [...],
...
}

Decouple responsibilities:
First agent: Extract data without worrying about the JSON.
Second agent or “Edit Fields” or “Information Extractor” node: Convert the output into the expected JSON for Google Sheets.

Check the Google Sheets node:
Use a separate “Google Sheets → Append row” node instead of the tool within the agent. Make sure the column mapping is up to date (reselect “Mapping Column Mode”). If you are processing multiple orders, you can separate the items with “SplitInBatches” or similar to ensure each JSON is handled correctly.

Suggested flow
[Input → AI Agent (extractor) → Reformatting node (Edit Fields / Info Extractor) → Google Sheets (Append row)]

[

{

“output”: “Your pickup order has been placed successfully, William! Here are the details:\n\n- Order ID: ORD-20250620-103014\n- Food Item: 1 Supremo Burrito with shredded beef\n- Special Instructions: None\n- Pickup Time: 11:15 AM\n- Phone Number: 720-414-3379\n\nLet us know if you need anything else!”

}

]

After updating the prompt, the AI agent is showing the JSON output in this format, yes the google sheet updated successfully, but why it is not showing in the json format instead of a general query.

Do you require the json input because you’re calling this from a webhook?

on the very first try the data updated in the google sheet perfectly, but on the second try it fails again, none of the tools called by the ai agent.

this is the issue i am facing from several days, sometimes the agent work perfectly but it fails on the second attempt. i am using n8n self hosted on hosting kvm-1 vps.

dont know whats the issue.

yes i am calling it from a webhook, i am using eleven labs AI agent and sending data from there to n8n to update in the sheets.

i tried 3rd time, but it is not sending the correct json format to the google sheet

Try this enhanced system prompt:

can you please send the prompt directly here in the comment

it is not working, same output. the output is not in json format.

I noticed after I posted. Busy fixing it now . One moment

it is like insane, first time it works perfect but on the other attempts it fails to provide json format. i am working on this workflow from 2 weeks as i am a beginner, and i am facing the same issue from the day 1

Try this updated version. It now responds with json and calls the tools correctly.

I used claude to attempt to enhance the prompt and it suggested this json format. Maybe try and use this structure and just update what you need to send back to your calling service. Its not exactly what you initially wanted, but it does work

Conversation output:

Id like to make a food order of 7 tacos

{
  "chatResponse": "Got it! You've ordered 7 tacos. May I have your name, phone number, and the time you'd like to pick up the order? Also, let me know if you have any special instructions.",
  "status": "gathering_info",
  "data": {
    "type": "order",
    "collected_fields": {
      "Food_Items": "Tacos",
      "Quantity": "7"
    },
    "missing_fields": ["Customer_Name__using_to_match_", "Phone_Number", "Time"]
  }
}
pete, 3787236486

{
  "chatResponse": "Thanks, Pete! What time would you like to pick up your 7 tacos?",
  "status": "gathering_info",
  "data": {
    "type": "order",
    "collected_fields": {
      "Customer_Name__using_to_match_": "Pete",
      "Phone_Number": "3787236486",
      "Food_Items": "Tacos",
      "Quantity": "7"
    },
    "missing_fields": ["Time"]
  }
}
19:00

{
  "chatResponse": "Perfect! Let me confirm: You've ordered 7 tacos for pickup at 7:00 PM under the name Pete. Contact number is 3787236486. Is this correct?",
  "status": "ready_to_confirm",
  "data": {
    "type": "order",
    "collected_fields": {
      "Customer_Name__using_to_match_": "Pete",
      "Food_Items": "Tacos",
      "Quantity": "7",
      "Phone_Number": "3787236486",
      "Time": "7:00 PM",
      "Special_Instructions": null
    },
    "missing_fields": []
  }
}
yes

{
  "chatResponse": "Your order has been placed! Order ID: ORD-20250620-112523. We'll have your 7 tacos ready for pickup at 7:00 PM.",
  "status": "order_placed",
  "data": {
    "type": "order",
    "order_id": "ORD-20250620-112523",
    "collected_fields": {
      "Customer_Name__using_to_match_": "Pete",
      "Food_Items": "Tacos",
      "Quantity": "7",
      "Phone_Number": "3787236486",
      "Time": "7:00 PM",
      "Special_Instructions": null
    }
  }
}

Results:

Oh so BTW, your chat memory is incorrect. You need some form of conversation id which is unique. In your original workflow you pasted, you set that to the Webhook object which might not work. This will cause memory issues for the agent and send it all over the place. Have a look at my final example here where I use the chat input and the conversation id as an example:

let me try.

not it doent work , i tried the prompt , but it remains the same json not passing correctly.

I fixed the prompt’s last line to not include the ``` json wrpper and then in the respond to webhook you need to map the $json.output as a Respond with JSON instead of the First Item

i have updated the prompt and respond to webhook node, but still issue remain same. dont know what is the issue.