← All posts
n8n python automation AI workflow

n8n vs Python Scripts: When to Use Each for Automation

· Mohd Hanafiah

n8n vs Python Scripts: When to Use Each for Automation

I get this question on almost every automation discovery call: “Should we use n8n or just write a Python script?”

Both can do most of the same things. The choice comes down to maintenance, flexibility, and who’s going to own the workflow long-term.

n8n: When visual wins

n8n is a self-hosted (or cloud) workflow automation tool with 400+ integrations. You build workflows by connecting nodes visually.

Use n8n when:

  • The client or their team needs to modify workflows themselves
  • You’re connecting mainstream apps (Gmail, Notion, Slack, HubSpot, Shopify)
  • You need the workflow running within days, not weeks
  • Error handling and retries need to be visible and manageable by non-developers
  • The logic is linear: trigger → transform → action

A typical n8n workflow I’ve built for clients: WhatsApp message comes in via the WhatsApp Business API → n8n parses it → checks if the sender is a known contact in HubSpot → if not, creates a new contact → assigns to the right sales team → sends an auto-reply.

That took 4 hours to build, test, and deploy. In Python it would have been 2+ days.

n8n’s limits:

  • Complex data transformation is clunky in the visual editor
  • Custom logic that doesn’t fit a node requires writing JavaScript inline (workable but ugly)
  • The self-hosted version needs a VPS with 1GB+ RAM

Python: When you need raw control

Python automation shines when the problem doesn’t fit a visual tool.

Use Python when:

  • You’re doing heavy data processing (cleaning, merging, analysing datasets)
  • The integration doesn’t have an n8n node and the API is complex
  • You need ML/AI processing inline (calling a model, parsing outputs, making decisions)
  • You’re building something that other code needs to import
  • Performance matters at scale (processing 100,000+ rows)

A Python script I recently built: daily scrape of a client’s competitors’ pricing pages, extract prices using an LLM, compare against client’s prices, flag any that are more than 10% divergent, and post a Slack summary. That workflow uses LangChain, BeautifulSoup, the Anthropic API, and the Slack SDK — none of which maps cleanly to n8n nodes.

The hybrid approach (what I use most often)

Real projects often combine both.

n8n handles the trigger and routing: “new order came in from Shopify.” Python handles the business logic: “calculate the optimal warehouse for this order based on stock levels and shipping distance.” n8n picks up the result and sends the notification.

This splits the work at the right seam:

  • n8n for integration glue and visibility
  • Python for computation and AI processing

Practical checklist

Use n8n if:

  • The workflow connects existing SaaS tools
  • You need non-developers to maintain it
  • You want a UI showing run history and errors
  • Timeline is tight

Use Python if:

  • You need custom algorithms or ML
  • You’re processing large datasets
  • The workflow is internal and developer-owned
  • You need maximum performance or flexibility

Use both if:

  • The trigger/routing is clean but the logic is complex
  • You want visibility on the n8n side and power on the Python side

Have a workflow you want automated? Tell me about it — I’ll scope it in a free discovery call.

Written by Mohd Hanafiah

Freelance developer and automation specialist from Malaysia. I build Astro sites, Flutter apps, AI automation workflows, and coach developers.

Work with me →