What this workflow does
This workflow sends your question to the Perplexity AI API and gets a clear answer back fast.
It stops you from doing boring copy-paste between apps.
You get clean, easy-to-read answers and their sources directly inside n8n.
The process starts when you press a button.
Then it sends your prompts and filters to Perplexity.
After that, it picks out the main answer and any citations.
Finally, it shows this result for you to use next.
Who should use this workflow
This is best for anyone who wants to quickly get good search-backed AI answers in n8n.
It helps people who do research or create content without switching tools.
No need to know code or API details – just use the workflow.
It works well for learning, summarizing, or finding facts with AI.
Tools and services used
- n8n Automation Platform: To build and run the workflow.
- Perplexity API Sonar Model: Provides AI answers based on search.
- Generic HTTP Credential: Holds the API Key securely.
Beginner step-by-step: How to use this workflow in n8n production
Download and Import Workflow
- Download the workflow JSON file using the Download button on this page.
- In the n8n editor, click on the menu and select “Import from File”.
- Choose the downloaded workflow file to add it to your workflows.
Configure the Workflow
- Add your Perplexity API Key in n8n by creating or updating the generic HTTP Credential.
- Check the Set nodes to update any questions, system prompts, or domain filters as needed.
- If there are IDs, emails, or other details, update them to fit your needs.
Test and Activate
- Run the workflow once by clicking the Execute button on the Manual Trigger node.
- Watch the output in the last Set node to ensure answer and citation data appear.
- If it works, turn on the active toggle for the workflow to use it regularly.
You are now ready to get AI answers inside n8n without extra copy-paste.
Inputs, Processing, and Output
Inputs
- System prompt to set AI role.
- User question prompt.
- Domain filters to limit search scope.
Processing Steps
- Manual trigger starts the workflow.
- The Set node packages prompts and domains.
- HTTP Request sends this data as a JSON body to Perplexity’s chat completions endpoint.
- API answers come back as JSON with choices and citations.
- Another Set node extracts just the answer text and citations for clean output.
Output
- Clean AI-generated answer text.
- List of citation sources for the answer.
Customization ideas
- Change the AI model in the HTTP Request JSON from
sonartosonar-profor advanced results. - Replace the fixed user prompt with dynamic input using a webhook or chat integration.
- Add or remove domains in the domain filter to focus or widen search areas.
- Enable
return_related_questionsto get extra suggested queries from the AI.
Troubleshooting common problems
- 401 Unauthorized errors: Check API key is correct and has the ‘Bearer ‘ prefix in the Authorization header.
- Empty or wrong answers: Confirm JSON syntax and expression fields are correct in Set and HTTP nodes.
- Workflow does not trigger: Make sure the Manual Trigger node is connected and used correctly.
Pre-Production Checklist
- Verify Perplexity API Key and HTTP Credential setup in n8n.
- Test manual trigger and check final Set node output.
- Check HTTP Request node returns data with choices and citations.
- Backup workflow before activating in production.
Deployment Guide
After testing, toggle the workflow to active inside the n8n editor.
You can run the workflow manually whenever needed or connect it to chatbots or other automations.
For users hosting n8n themselves, monitor execution logs and API usage carefully, using self-host n8n resources as helpful.
The workflow JSON snippet for the HTTP Request body
Copy this JSON into the HTTP Request node’s body parameters to connect dynamic inputs properly.
{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "{{ $json.system_prompt }}"
},
{
"role": "user",
"content": "{{ $json.user_prompt }}"
}
],
"temperature": 0.2,
"top_p": 0.9,
"search_domain_filter": {{ (JSON.stringify($json.domains.split(","))) }},
"return_images": false,
"return_related_questions": false,
"search_recency_filter": "month",
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 1,
"response_format": null
}Extracting AI answer and citations from API response
Use this expression in a Set node to cleanly grab needed fields from the full API reply.
output = {{ $json.choices[0].message.content }}
citations = {{ $json.citations }}Summary
✓ Automates sending questions to Perplexity and receiving answers.
✓ Reduces time spent copying and pasting.
✓ Returns concise AI answers with references.
✓ Easy to install and test in n8n.
✓ Flexible for different prompts and domains.

