How to give your Cursor AI Agent a Webhook Listener
Cursor agents are powerful but reactive. Learn how to give your AI agent a 'Mailbox' so it can autonomously react to external events like payments or GitHub alerts.
The Cursor Tool Primitive
# Add this to your project so Cursor can 'see' it
def check_mailbox():
"""Check for new external triggers from FetchHook."""
import requests
res = requests.get("https://api.fetchhook.app/api/v1/stash_123",
headers={"Authorization": "Bearer fh_xxx"})
return res.json()#Why do Cursor agents need a mailbox?
Normally, you have to tell Cursor what to do. But what if you want your agent to work while you're away? By giving Cursor a tool to 'check the mail,' the agent can autonomously poll for work. You point your services (Stripe, GitHub, etc.) to FetchHook, and the agent periodically checks for new events to action.
#The 'Continuous Agent' Pattern
In your `.cursorrules` or system prompt, instruct the agent: 'Before starting your loop, call check_mailbox(). If new events exist, process them according to the defined logic.' This turns Cursor from a chat-bot into a proactive automation agent.
Agent Protocol Instruction