Agent AI doesn't handled webhooks well

I tested with chat and built in app agent ai works without issue but if data
is coming from the webhook and you add response webhook
ai agent doesn’t execute the node

Any idea or is this a bug?

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi,

Could you provide your workflow to see what is happening?

Here is the flow, what happens is when I used webhook, it only runs those nodes

event though my prompt is only
use book_appointment tool before response to Webhook

Please share the workflow code. Just select all nodes, copy and paste here inside a code block.

all nodes are set to default

in ai agent i have this prompt

hold on not sure how to do that

  1. Select all the nodes

  2. Copy

  3. Create a code block here
    ```
    This is a code block
    ```

  4. Paste inside the code block

The agent only knows about the nodes underneath it, not the nodes to the right.

If you want the ‘book appointment’ step to always happen, better to put it as a regular (square) node in between the agent and the ‘respond to webhook’. You can then get the agent to output the details of the booking and wire them up.

I could do that and won’t have an issue but I trying to see why agent AI is not handling that part when using webhook. When I used chat or telegram it works
so I find it weird

P.S. I am running the same post data which is
{"email": "[email protected]"}

1 Like

The issue is likely due to how the AI agent processes and executes tools within n8n. Since the AI agent only knows about the nodes beneath it, but not the ones to the right, it might not be triggering the book_appointment tool properly before the Respond to Webhook step.

Fix: Restructuring the Workflow

Steps to Fix It

  1. Move the book_appointment tool into the main execution path
  • Instead of relying on the AI agent to call the book_appointment tool, insert it as a regular node between the AI agent and Respond to Webhook.
  • This ensures that book_appointment will always execute before the webhook responds.
  1. Modify the AI agent’s output
  • Make sure the AI agent outputs structured data containing the appointment details.
  • Connect the output of the AI agent to the book_appointment node.
  1. Ensure Execution Order
  • Connect the book_appointment node output to Respond to Webhook, so it only executes after the appointment is booked.

Updated Flow Structure

  1. Webhook → 2. AI Agent → 3. Book Appointment Node (Direct Execution, Not via AI Tool Call) → 4. Respond to Webhook

This structure guarantees that the appointment booking happens before responding to the webhook.

Would you like me to help modify your workflow with step-by-step changes? this was a chat gpt reply

Thanks I understand that flow would work but the concern I have the agent not recognizing the tools underneath it when you put respond webhook.

I also wonder why Respond webhook cannot be added under tools of AI agent

A.I. agent also does not recognized command like

e.g.
Use the following hook in order

  1. use hook_1
  2. use hook_2
  3. use hook 3

Agents can be unreliable with complicated instructions. Could it be that whether your agent calls the tool isn’t related to whether there’s a webhook but down to the natural variability of what the agent chooses to do?

In general you should try to make the instructions to AI as simple as possible. So if you want it to call 3 tools in a certain order, turn them into a single tool that always does that.

You can do that by creating a sub-workflow with regular (square) nodes that perform your three actions in sequence, and adding that workflow as a tool for the agent.

Thanks I actually did that, still it didn’t call the tools while using webhooks
I will try to experiment on it more

https://medium.com/@balci.pelin/n8n-webhook-ec9de8e4200c