What You Will Build: A Behavior Driven AI Agent Pipeline

You have a SaaS product, an ecom store, or a B2B funnel. You know users are doing things on screen. Maybe they open your pricing page and stare at the Enterprise tier. Maybe they hover over a checkout button then leave. Traditional analytics tells you a pageview happened. It does not tell you what the user actually saw or how long they fixated on a specific element.

Here is the gap. Most teams rely on clickstream data and heatmaps. They miss the richest signal: the raw pixels of the user's screen. Screenpipe captures this. It records at up to 30 frames per second, generating roughly 108,000 images per hour of screen time. Feeding that into an AI agent pipeline no code style lets you extract behavioral intent in real time.

This tutorial wires Screenpipe to n8n via webhooks. The workflow receives batched OCR text or frame summaries, an LLM classifies the user's intent, and n8n executes an action: update a CRM, adjust a Google Ads bid, or send a personalized video email. All without writing a single line of server code. The no code promise holds because n8n's Webhook, HTTP Request, Wait, and IF nodes handle every step.

By the end you will have a running prototype that can detect when a trial user engages with your Enterprise pricing table and automatically trigger a tailored follow up. The same pattern works for ad optimization: if a user repeatedly views competitor comparison pages, pause your retargeting bid and serve a testimonial instead. Let's build it.

Prerequisites and Setup: Install Screenpipe n8n

You need two tools running on the same machine (or network). Both are free and open source.

  • Screenpipe: cross platform screen recorder with built in OCR. Install on macOS via Homebrew. For Linux or Windows use the prebuilt binaries from the Screenpipe GitHub repository.
  • n8n: workflow automation platform. Run locally via Docker or use the free tier of n8n Cloud 2.0 (up to 5,000 workflow executions per month). The cloud version includes webhook support out of the box. Refer to n8n documentation for setup.

After installing Screenpipe, enable differential recording. Append the flag --differential when starting the process. This cuts the data volume by 80 to 90 percent because it only sends frames where pixels changed. That is critical for keeping your LLM costs and storage in check.

screenpipe --differential --ocr --port 3030

Now configure the webhook inside Screenpipe's config.json file. Set the webhook_url to your n8n endpoint:

{
  "differential": true,
  "batch": 5,
  "webhook_url": "http://localhost:5678/webhook/screenpipe"
}

The batch: 5 setting tells Screenpipe to collect 5 seconds of frames before sending them as a single JSON payload. This reduces trigger load on n8n. Start Screenpipe and verify the process runs on port 3030.

For n8n, create a new workflow. Add a Webhook node, set the method to POST, and copy the URL. That URL goes into your Screenpipe config. When both services are running, open a target webpage and watch the n8n execution logs. You should see incoming JSON payloads appearing every 5 seconds.

Step 1: Capture User Behavior with Screenpipe Differential Recording

Plain continuous screen recording produces massive amounts of data. A 10 second dump of 300 images can easily exceed n8n's 25 MB webhook payload limit. Differential recording solves this by sending only the changed regions. In practice, most user sessions involve long static periods (reading an article, staring at a dashboard). Only the moments where something moves get transmitted.

To enable differential mode, set "differential": true in your config.json as shown above. You can also pass the --differential CLI flag. The batch parameter groups frames from a time window. I recommend batch=5 seconds. This gives you enough context to interpret behavior without flooding the webhook.

Screenpipe's OCR (using Tesseract v5) achieves roughly 95% accuracy on clean UIs. On complex backgrounds or low light recordings, accuracy drops to 65-75%. Be aware of this when you design the LLM prompt. If the extracted text is garbled, the AI will struggle. You can optionally feed raw frame buffers into a Vision API for better accuracy, but that raises cost per analysis (GPT 4 Turbo costs $0.01 per 1K input tokens, so a single frame analysis runs $0.001 to $0.01). For many use cases the built in OCR is good enough, especially when you only care about keywords like "Enterprise" or "Pricing".

To test the feed, start a browser and visit your own pricing page. Check n8n's execution list. You should see POST requests with a JSON body containing an array of frames, each with OCR text, timestamp, and bounding box coordinates.

Step 2: Build the n8n Workflow; Trigger, Filter, Enrich, Decide

Open your n8n workflow. The first node is the Webhook trigger. Its output will be the raw JSON from Screenpipe. We need to filter for relevant behavior and then ask an LLM for a decision.

Trigger and Filter

Add an IF node after the webhook. Use n8n's expression editor to check if any frame's OCR text contains a target keyword. This is a simple regex match and requires zero coding. Example expression:

{{ $json.frames.some(frame => frame.ocr_text.toLowerCase().includes('enterprise')) }}

If the condition is true, the workflow continues. False branches can be discarded or logged for later analysis. This filter alone eliminates 90% of unnecessary LLM calls, saving money.

Debounce with Wait

Users often scroll past a pricing table quickly. A single scroll should not trigger an action. Insert a Wait node set to 30 to 60 seconds. The workflow will pause. During this time, Screenpipe continues sending payloads. After the wait, you need to check if the user is still viewing the Enterprise section. You can create a second IF node that looks for the same keyword in the most recent frame batch. If it still matches, the user has sustained attention. This simple debounce pattern prevents false positives.

Enrich with LLM

Now call an LLM to interpret the behavior. Use an HTTP Request node. The URL points to the chat completions endpoint of your chosen model. I recommend Claude 3 Haiku for speed and cost ($0.00025 per 1K tokens for text only). If you need to analyze an actual frame image (not just OCR text), use the Vision API from OpenAI API docs but expect higher latency and cost.

Your prompt should output a simple structured decision. For example:

{
  "model": "claude-3-haiku-20240307",
  "max_tokens": 50,
  "messages": [
    {"role": "system", "content": "You are a behavior analyst. Given OCR text from the user's screen, determine if they have been viewing the Enterprise pricing table for more than 10 seconds. Reply only 'yes' or 'no'."},
    {"role": "user", "content": "OCR text: {{ $json.frames[0].ocr_text }}"}
  ]
}

The response will be a short JSON. Add another IF node to parse the result. If 'yes', proceed to action. This is the n8n webhook LLM decision loop, running in roughly 2 seconds total.

Step 3: Automate Actions; Send Emails, Update CRM, Optimize Ads

Once the AI decides the user is deeply interested in Enterprise pricing, you need to perform an action. n8n has native nodes for many marketing tools. For a SaaS company, the natural action is a personalized follow up email or a CRM update.

Use the HubSpot node to create a contact task or update a custom property like "Enterprise Interest Score". Alternatively, use a SendGrid node to send an email that links to a personalized demo video. The example from the brief: send an Enterprise video tutorial to that user within seconds of them finishing their session.

For ad optimization, connect to Google Ads or Meta Ads via the HTTP Request node. Build a payload that adjusts bids or pauses underperforming campaigns based on observed behavior. For instance, if a user viewed the competitor comparison page, you could lower your retargeting bid for that user because they may be price shopping. That is n8n ad optimization automation driven by real behavioral signals rather than guesswork.

Add a final IF node to cap frequency. You do not want to email the same user every time they glance at pricing. Set an n8n variable or use a simple counter in a data store to limit actions to one per session. This keeps you inside API rate limits and avoids annoying your leads.

Pitfalls and Pro Tips: Making Your Agent Production Ready

Building this pipeline in a demo environment is easy. Running it in production introduces several traps you must navigate.

OCR Accuracy Degradation

Screenpipe's OCR accuracy drops to 65-75% on complex UIs with overlapping windows, pop ups, or animations. If your LLM receives garbled text, its decisions become unreliable. Solution: send the raw frame image to a Vision API (like GPT 4 Vision) for frames where OCR fails. Use a pre filter: check the confidence score of the OCR output (available in the JSON payload). If confidence is below 0.8, route to Vision. This adds cost ($0.01 per analysis) but saves you from false positives that waste ad spend.

Webhook Payload Size

n8n's webhook node has a 25 MB payload limit. A 10 second batch of 300 uncompressed images can exceed that. Always use differential recording and batch settings. Further reduce payload by sending only the OCR text and bounding boxes, not the full base64 encoded images. You can configure Screenpipe to strip images in its webhook output. Refer to the output_mode option in its config.

High Throughput Limitations

If you are monitoring multiple users (e.g., a team of sales reps or user testers), a single n8n instance can struggle with concurrent webhook events exceeding 100 per second. Use an Event Driven Execution pattern. n8n's Execution Library node (introduced in 2025) allows you to queue incoming data and process in batches. Alternatively, push Screenpipe data to a Redis buffer and have n8n pull from it at a controlled rate.

Local vs Cloud Tradeoff

Running Screenpipe and n8n locally keeps screen data private, ideal for GDPR compliance. But it limits your LLM options to small local models. You can run a model like SmolLM 2 from Hugging Face directly on CPU in under 100ms for simple text classification. This makes a great pre filter: classify whether the screen contains an error modal, checkout step, or pricing page without any internet call. Only forward the anonymized textual summary to a cloud LLM for the final decision. This hybrid approach keeps 90% of processing free and secure.

Key Trap: Over triggering. Marketers new to Screenpipe want "every scroll equals email". This floods the user. Always build a decay. Use the Wait node and a condition that checks for repeated negative patterns (e.g., same frame content three times in 30 seconds) before acting. Your alerts will drop by 80% and user satisfaction will improve.

Next Steps

Once your pipeline is running, expand it. Connect multiple Screenpipe instances for team monitoring. Build a dashboard in Redash or Metabase that shows behavioral funnels: see what happened before a conversion. You now have a system that turns raw screen pixels into automated actions, all without a dedicated developer.

This is a powerful engine, but it requires careful tuning. If you would rather have someone set this up for you in a fixed two week sprint, including the Screenpipe configuration, n8n workflow, LLM prompt engineering, and integration with your CRM or ad platform, we can do that. Our Growth Sprint covers exactly this: a complete pipeline built for $1,500, no retainer. You get the working system and the documentation. From there you can iterate yourself or let us manage the scaling.

Start small. Run the filter for one keyword. Watch the execution logs. Then layer in the LLM decision. Once it works, you will never want to optimize campaigns based on guesses again.

Cover photo by Milad Fakurian on Unsplash.