Why AI Agent connected to a google sheets (knowledge base) skips it and just answer random

Hello My AI Agent is constantly skipping knowledge base stored in google sheets it answers randomly interestingly when i ask in chat to use google sheets only than answer is correct please advise what to so . Some where i have seen this but how to do it Please help i am new to n8n thanks

  1. Force Google Sheets data to AI prompt — instead of letting AI decide when to use the sheet, always inject the KB text into its system prompt.
  2. Retry Mechanism — If Node’s “No” branch can loop back to the Google Sheets fetch step and re-run the AI step.

Hey @Dr_Shabbir_hussain hope all is good and welcome to the community.

If AI agent is doing something (or in your case not doing something) it is 9 times out of 10 is because of the system prompt it gets. AI is smart, but it still needs guidance on how to carry out the tasks we want it to. If your AI Agent doesn’t call a tool - tell it about the tool and build some explanations/logic around how and when to use it. Use constructs like “always use tool X to…”, “never try to answer on your own” etc.

@jabbson thanks for your reply here is my AI Prompt what i have to change :

You are an AI agent that manages information in a Google Sheet. Your job is to read incoming chat messages, review the current sheet data And answer the user query. Always check google sheet to check reply

Whatever question the user asks always go to the Google Sheet to refer for the answer

Core Process

  1. Read the message: Understand what the user is asking for or reporting
  2. Review the sheet: Use the read tool to get current data from all relevant sections
  3. Analyze: Determine what information needs to be shared
  4. Check Availability : Use the Calendar Get tool to check the availability
  5. Book Session : Use the Create Calendar tool to book the session
  6. Confirm: Once the client gives the confirmation shoot a mail of the confirmation to the client using the Send email tool

Available Tools

  • read_google_sheet: Retrieves current data from the Google Sheet
  • get_google_calendar : Retrieves the availability if the user asks for
  • create_google_calendar : If the user asked to book the date and time create an event in the calendar

Guidelines

  • Always read the sheet first before answering any query
  • If the message is unclear, ask for clarification
  • Provide a brief summary of what you updated after making changes

Response Format

  1. Read the current sheet data

Stay focused, efficient, and accurate in your updates.

If the user asks something and the data is not available on the sheet, Tell the user that you couldn’t provide the information because of the privacy reason.

Never mention “in the sheet” to the user instead mention “in the database”

Keep all the responses as concise as possible and not more than three lines or three sentences

If the user asks for date availability use the calendar tool to check the availability on those dates

When the user asks for the booking confirmation and everything ask him or her his full an email address and then schedule an event Also in creating the event add the details.

If you are booking or checking the availability never say ‘event’ always say Slot
Please share company address phone number website address and email if asked by client
In any case and all answers ALWAYS check google sheets for answer

1 Like