Query Perplexity AI for Cited, Domain-Specific Answers - n8n Workflow

Use this specialized n8n workflow to leverage the power of Perplexity AI within your automation projects. Configure system prompts, user questions, and restrict searches to specific domains using a custom n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers and Technical Content Writers who need accurate, cited LLM outputs.

  • Users looking for advanced RAG (Retrieval-Augmented Generation) capabilities outside standard OpenAI/Anthropic integrations.

  • Anyone seeking a ready-to-use n8n template for connecting to external AI services using the HTTP Request n8n node.

  • Automation specialists building complex n8n workflows requiring real-time internet search capabilities.

Overview

While many LLMs provide robust natural language generation, Perplexity AI excels at providing grounded, cited answers based on real-time web searches. This n8n workflow is designed to streamline that integration. Instead of manually querying the API, this n8n template allows you to pre-define the AI's persona (systemprompt), the specific question (userprompt), and critically, a list of trusted domains (domains) the AI must restrict its search to.

This setup ensures your resulting content is highly relevant and grounded, making this n8n workflow essential for content research, competitive analysis, or automated fact-checking tasks. It demonstrates how easily powerful external services can be managed within an n8n environment using the HTTP Request n8n node.

How it Works

This powerful n8n workflow follows a linear path, starting with a test trigger and concluding with structured output:


  1. Manual Start: The automation begins with the 'When clicking ‘Test workflow’' n8n trigger, ideal for testing and development before integrating it into a larger production n8n workflow.

  2. Define Parameters: The 'Set Params' n8n node injects the necessary input variables: the AI's role (systemprompt), the query itself (userprompt), and the comma-separated domains (domains) to restrict the AI's search.

  3. API Request: The 'Perplexity Request' n8n node (an HTTP Request n8n node) sends a POST request to the Perplexity API. It dynamically constructs the complex JSON payload, incorporating the defined prompts and the domain filter. The credentials for API Key authentication are handled securely by n8n.

  4. Data Extraction: The final 'Clean Output' n8n node processes the JSON response from Perplexity. It cleanly extracts the final generated text and, importantly, the list of citations/sources, providing a standardized, clean output ready for use in subsequent steps of the n8n workflow.

Installation Guide

To deploy this n8n template and run your first Perplexity query, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and import it directly into your n8n instance via the 'New' menu -> 'Import from JSON'.

  2. Set Up Perplexity API Key:

Go to the Perplexity dashboard and generate an API key.
In your n8n instance, locate the 'Perplexity Request' n8n node.
Set up a new credential for 'HTTP Header Auth'.
Name the header 'Authorization'.
* The value must be Bearer YOURAPIKEY (e.g., Bearer pplx-e4...).

  1. Configure Inputs: Update the 'Set Params' n8n node to reflect your desired user_prompt and target domains (e.g., 'wikipedia.org, techcrunch.com').

  2. Test the n8n Workflow: Execute the n8n trigger to verify the connection and receive your cited AI output.

Node Details

When clicking ‘Test workflow’ (Manual Trigger n8n trigger):
Function: Starts the n8n workflow on command, essential for development and initial testing of this n8n template.
Set Params (Set n8n node):
Function: Defines the three crucial variables for the AI request: systemprompt, userprompt, and the domains array. This is the main point of configuration for the user.
Perplexity Request (HTTP Request n8n node):
Function: Executes the core AI operation. Sends a complex JSON payload specifying the 'sonar' model, the prompts, and the critical searchdomainfilter based on the input from the previous n8n node.
Key Configuration: Uses 'POST' method to https://api.perplexity.ai/chat/completions. Requires HTTP Header Authentication for the Perplexity API key.
Clean Output (Set n8n node):
* Function: Parses and formats the AI response, extracting the final message content into an output variable and the source URLs into a citations array. This cleans up the raw JSON output from the previous n8n node, making the data ready for further automation steps in your n8n workflow.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

🎉 Do you want to master AI automation, so you can save time and build cool stuff? I’ve created a welcoming Skool community for non-technical yet resourceful learners.

Featured*