Skip to content
AI agent not sendin...
 
Notifications
Clear all

AI agent not sending data in JSON format to update Google Sheets

19 Posts
3 Users
0 Reactions
8 Views
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

Describe the problem/error/question

My AI agent is not formatting data into JSON, nor updating the Google Sheet fields. I am collecting orders and reservations and updating them 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.nnCurrent date {{ $now }}nn## Voice & Tone Guidelinesn- 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.nnn## Order Processingnn1. 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**nn2. 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.nn## Reservation Processingnn1. 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**nn2. 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.nn## JSON Input Format for Tools (VERY IMPORTANT)nnWhen 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.nn### For `update_food_orders_sheet` (Order):n```jsonn{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):nJSONnn{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 NotesnPlease 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.nExamplesnOrdernCustomer: “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.nnReservationnCustomer: “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.nnToday is {{ $json.today }}.nWhen someone asks about today’s specials, only respond with the items under {{ $json.today }}.nnHere are the daily specials:nnMonday: Margarita Monday – House Rita $5, Domestic Craft $2.50, Supremo Burrito $16nTuesday: Taco Tuesday – Mexican Taco $2.50, American Taco $1.99, House Sangria $6, Moscow Mule $7, Arroz Con Pollo $16, Carnitas De Pollo $16nWednesday: Loco Wednesday – Super Chimichanga $15, Enchiladas $15, Mojitos $7, Skinny Rita $8nThursday: Thirsty Thursday – Super Nachos $11, Chicken Fajitas $17, Cadillac Rita $9, Jalapeño Cucumber Margarita $9, Raspberry Rita $8nFriday–Sunday: No daily specials, just Happy Hour.nHappy Hour (Every day 11am–7pm):nnHouse Sangria $6, House Rita $5, House Wine $6, Domestic Beer $2.50nToolsnOpenAI 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,
              "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": [
        0,
        500
      ],
      "id": "d9130fe9-d6d3-48be-adc0-23288c138f4a",
      "name": "Get Confirmed Reservation",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "9F1NALsPOKCXZMRy",
          "name": "Inca Media Google Sheet"
        }
      }
    },
    {
      "parameters": {
        "content": "## Handling Ordersn",
        "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 Reservationsn",
        "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"];nnitems[0].json.today = weekdays[date.getDay()];nnreturn 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"
      },
      "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. nnShall I go ahead and place this order?”

}

]

Information on your n8n setup

  • n8n version: 1.98.2
  • Database (default: SQLite): don't know
  • n8n EXECUTIONS_PROCESS setting (default: own, main): self hosted
  • Running n8n via (Docker, npm, callin.io app, desktop app): docker
  • Operating system: hostinger vps

Please provide the rewritten markdown content *it should be in the markdown format.

 
Posted : 20/06/2025 1:26 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

Here’s the solution. Instead of providing the AI prompt with a complex JSON structure, simply outline the available tools. The AI Agent node and its sub-node tools are capable of determining the necessary information sources. After implementing this change, I observed that reservations and orders began functioning correctly.

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)
 
Posted : 20/06/2025 1:52 pm
Erick_Torres
(@erick_torres)
Posts: 9
Active Member
 

In the AI Agent, enable “Require Specific Output Format” and define the expected JSON schema using built-in tools.

Example:

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

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

Check the Google Sheets node:
Utilize a separate “Google Sheets → Append row” node rather than the tool within the agent. Ensure the column mapping is current (reselect “Mapping Column Mode”). If you are processing multiple orders, you can separate the items using “SplitInBatches” or a similar method to guarantee each JSON is managed correctly.

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

 
Posted : 20/06/2025 1:53 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

json
{
“output”: “Your pickup order has been placed successfully! Here are the details:nn- __Order ID:__ ORD-20250620-103014n- __Food Item:__ 1 Supremo Burrito with shredded beefn- __Special Instructions:__ Nonen- __Pickup Time:__ 11:15 AMn- __Phone Number:__ 720-414-3379nnLet us know if you need anything else!”
}

After updating the prompt, the AI agent is displaying the JSON output in this format. Yes, the Google Sheet updated successfully, but why is it not showing in JSON format instead of a general query?

 
Posted : 20/06/2025 2:34 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

Do you need the JSON input because you're invoking this from a webhook?

Could you please share the JSON input?

 
Posted : 20/06/2025 2:38 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

On the initial attempt, the data updated in the Google Sheet flawlessly. However, on the second attempt, it fails again, and none of the tools invoked by the AI agent are called.

This issue has been persistent for several days; sometimes the agent functions perfectly, but it fails on subsequent attempts. I am operating a self-hosted instance of callin.io on a hosting kvm-1 VPS.

I'm unsure about the cause of this problem.

 
Posted : 20/06/2025 2:41 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

Yes, I'm triggering it from a webhook. I'm utilizing the Eleven Labs AI agent and passing the data from there to callin.io to update the sheets.

 
Posted : 20/06/2025 2:42 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

I've attempted this three times now, but the JSON format being sent to the Google Sheet isn't correct.

 
Posted : 20/06/2025 2:53 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

Consider this refined system prompt:

 
Posted : 20/06/2025 3:01 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

Could you please share the prompt directly in this comment?

 
Posted : 20/06/2025 3:03 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

It's not functioning as expected; the output remains the same and is not in JSON format.

 
Posted : 20/06/2025 3:11 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

I noticed that after I posted. I'm currently working on fixing it. Please bear with me for a moment.

 
Posted : 20/06/2025 3:14 pm
hamidartist233
(@hamidartist233)
Posts: 11
Active Member
Topic starter
 

It's quite frustrating; the first attempt works flawlessly, but subsequent attempts fail to provide the JSON format. I've been working on this workflow for two weeks as a beginner, and I've encountered this same issue since day one.

 
Posted : 20/06/2025 3:18 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

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. It's 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:

 
Posted : 20/06/2025 3:26 pm
Wouter_Nigrini
(@wouter_nigrini)
Posts: 31
Eminent Member
 

Just a heads-up, your chat memory configuration seems to be incorrect. You need a unique conversation ID. In the workflow you shared previously, you set this to the Webhook object, which might not be reliable. This can lead to memory issues for the agent and cause it to behave erratically. Please review my final example here, where I utilize the chat input and a conversation ID:

 
Posted : 20/06/2025 3:32 pm
Page 1 / 2
Share: