Hey everyone
I’m building an AI agent in n8n that scrapes emails from Google Maps results, classifies them, and saves the data to Google Sheets. Here’s the current flow:
- Telegram Trigger: The user sends a keyword via Telegram, e.g.
fencing+suppliers+melbourne
- HTTP Request: Fetches the URL
https://www.google.com/maps/search/{keyword}
- Code Node: Scrapes business URLs from the HTML response
- Filter: Removes irrelevant URLs
- Remove Duplicates
- HTTP Request (per URL): Visits each website
- Code Node: Scrapes emails from the web page
- Aggregate email arrays
- Split out each email
- Remove duplicate emails
- Filter irrelevant emails
- Edit Fields: I group the email and URL to send to the AI agent (image below)
- The email field maps fine (from the “Filter irrelevant emails” node)
- The URL field is the issue — I’m trying to map it from the “Remove duplicate URL” node, but that node contains a list of 20+ URLs
- So n8n throws this error:
Multiple matching items for expression [item 0]
An expression here won’t work because it uses .item and n8n can’t figure out the matching item. (There are multiple possible matches)Try using .first(), .last() or .all()[index] instead of .item or reference a different node.
- AI Agent classifies:
- URL
- Company category
- Company name
- Scrape date
- Edit Fields: I map the AI output
- Google Sheets: Final structured data is stored
My question:
How can I correctly map the matching URL to each email in the “Edit Fields” node? The emails are split already, but the URLs are still in a list — how can I ensure the correct URL matches the right email during mapping?
If anyone wants to see the inside of any specific node (since I can’t include all screenshots in this post), just let me know which one you’re interested in and I’ll share it.
Thanks in advance
Information on your n8n setup
- n8n version:1.86.1
- Database (default: SQLite):
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app):
- Operating system: