Answer Real Estate Questions with AI Using PropertyFinder.ae, OpenRouter, and SerpAPI https://n8nworkflows.xyz/workflows/answer-real-estate-questions-with-ai-using-propertyfinder-ae--openrouter--and-serpapi-8309 # Answer Real Estate Questions with AI Using PropertyFinder.ae, OpenRouter, and SerpAPI --- ### 1. Workflow Overview This n8n workflow, titled **"Answer Real Estate Questions with AI Using PropertyFinder.ae, OpenRouter, and SerpAPI"**, is designed to serve as an AI-powered real estate assistant focused on properties in the UAE. Its primary function is to interpret user queries related to real estate, extract property details from a provided PropertyFinder.ae listing URL, and respond intelligently using a combination of scraped property data and external search via SerpAPI when needed. The workflow is logically divided into the following blocks: - **1.1 Input Reception and Context Retrieval**: Captures incoming chat messages, manages conversational memory, and extracts relevant URLs from the conversation. - **1.2 Property Data Scraping and Summarization**: If a valid property link is found, scrapes the property page HTML and processes it into a structured summary usable by the AI. - **1.3 AI Agent Query Processing**: Uses an AI agent powered by OpenRouter to answer user questions, leveraging the property summary as a knowledge base and falling back to SerpAPI search for missing information. - **1.4 Data Merging and Output Preparation**: Combines the enriched user message and listing summary for the AI agent to generate an informed response. --- ### 2. Block-by-Block Analysis #### 2.1 Input Reception and Context Retrieval **Overview:** This initial block captures the user's incoming chat message, retrieves recent conversation history to maintain context, and extracts the most relevant property listing link from the message or past conversation. **Nodes Involved:** - Chat input - Chat Memory Manager - Find link - If msg contains link - Capture Incoming Message - Simple Memory1 **Node Details:** - **Chat input** - *Type*: Langchain Chat Trigger - *Role*: Entry point; triggers workflow on new chat messages. - *Configuration*: Public webhook, initial greeting message "Hello!", no advanced options. - *Input/Output*: Input via webhook, outputs chat message data including session ID. - *Potential failures*: Webhook misconfiguration, missing sessionId in payload. - *Notes*: Essential for triggering entire workflow with user input. - **Chat Memory Manager** - *Type*: Langchain Memory Manager - *Role*: Retrieves and manages conversation history for context. - *Configuration*: Default options, no custom parameters. - *Input*: From Chat input node. - *Output*: Provides conversation messages array used downstream. - *Failures*: Memory access issues or data corruption can cause errors. - **Simple Memory1** - *Type*: Langchain Memory Buffer Window - *Role*: Maintains a sliding window of up to 30 past messages as a session-based context buffer. - *Configuration*: Uses sessionId from chat input as custom key, context window length 30 messages. - *Input/Output*: Input from Chat input, output used by Chat Memory Manager. - *Failures*: Session key missing or malformed. - **Find link** - *Type*: Code Node - *Role*: Extracts the most recent URL from the current chat input or from recent conversation history. - *Configuration*: Uses JavaScript to parse text and conversation for HTTP/HTTPS URLs, returns the last found link or empty string. - *Key expressions*: Regex to find URLs, logic to fallback search messages array. - *Input*: JSON with chat input message and conversation messages. - *Output*: JSON with a single property `link`. - *Failures*: Regex failure, empty or malformed chat input, no URLs found. - **If msg contains link** - *Type*: If Node - *Role*: Checks if the extracted link is non-empty to decide workflow branching. - *Configuration*: Condition: `link` field is not empty string. - *Input*: From Find link node. - *Output*: Two branches: true (link found) and false (no link). - *Failures*: Incorrect condition evaluation if input missing. - **Capture Incoming Message** - *Type*: Set Node - *Role*: Stores the raw user message and initializes the `listing_summary` field empty. - *Configuration*: Assigns `message` from chat input, `listing_summary` set to empty string. - *Input*: From If msg contains link (false branch). - *Output*: JSON with user message and empty listing summary. - *Failures*: None expected. --- #### 2.2 Property Data Scraping and Summarization **Overview:** When a valid property link is detected, this block scrapes the HTML content of the listing page and processes it into a well-structured summary suitable for AI consumption. **Nodes Involved:** - Scrape - Summarize - Capture **Node Details:** - **Scrape** - *Type*: HTTP Request - *Role*: Fetches the raw HTML content of the property listing page. - *Configuration*: - URL dynamically set from `Find link` node output. - Custom User-Agent header to mimic a real browser. - On error: continue workflow without failure (to handle broken links gracefully). - *Input*: URL string from Find link. - *Output*: Raw HTML content of the page. - *Failures*: HTTP errors (404, 403, timeouts), network failures, anti-bot blocks. - **Summarize** - *Type*: Code Node - *Role*: Parses the HTML content to extract key property details into a concise text summary optimized for AI prompt use. - *Configuration*: - Uses `cheerio` library for HTML parsing. - Extracts JSON embedded in `