The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "chat",
"responseMode": "responseNode",
"options": {}
},
"type": "n8n-nodes-base.webhook",
"typeVersion": 2.1,
"position": [
0,
0
],
"id": "2cfe661b-fdd4-4026-a082-867b2a1ab328",
"name": "Incoming_request"
},
{
"parameters": {
"jsCode": "const input = $input.item.json;\nconst messages = [];\n\n// System message\nmessages.push({\n role: \"system\",\n content: `You are an assistant that extracts stock or crypto tickers if they exist.\n\nReturn VALID JSON ONLY in this format:\n{\n \"text\": string,\n \"ticker\": string | null\n}\n\nRules:\n- Use standard tickers (AAPL, TSLA, BTCUSDT, SPX)\n- If no ticker is clearly mentioned or implied, set ticker to null\n- Do not invent tickers\n- No markdown code blocks\n- No backticks\n- Raw JSON only`\n});\n\n// Add conversation history if provided\nif (Array.isArray(input.history)) {\n for (const msg of input.history) {\n if (msg.role && msg.content) {\n messages.push({ role: msg.role, content: msg.content });\n }\n }\n}\n\n// Add current user message\nconst userMessage = input.message || input.body?.message || \"\";\nif (userMessage.trim()) {\n messages.push({ role: \"user\", content: userMessage });\n}\n\nreturn { \n session_id: input.session_id || input.body?.session_id || \"default-session\", \n messages \n};"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
240,
0
],
"id": "prepare-prompt",
"name": "Prepare Prompt"
},
{
"parameters": {
"method": "POST",
"url": "https://api.perplexity.ai/chat/completions",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "httpBearerAuth",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({\n model: \"sonar-pro\",\n messages: $json.messages,\n temperature: 0\n}) }}",
"options": {
"timeout": 30000
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.3,
"position": [
480,
0
],
"id": "perplexity-api",
"name": "Perplexity API",
"credentials": {
"httpBearerAuth": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "const response = $input.item.json;\n\n// Extract content from Perplexity response\nlet content = response.choices?.[0]?.message?.content || \"\";\n\n// Remove markdown code blocks and backticks\ncontent = content\n .replace(/```json\\s*/gi, '')\n .replace(/```\\s*/g, '')\n .replace(/^`+|`+$/g, '')\n .trim();\n\n// Try to extract JSON if there's extra text\nconst jsonMatch = content.match(/\\{[\\s\\S]*\\}/);\nif (jsonMatch) {\n content = jsonMatch[0];\n}\n\n// Parse JSON\nlet parsed;\ntry {\n parsed = JSON.parse(content);\n} catch (error) {\n // One more attempt with line breaks removed\n content = content.replace(/[\\r\\n]+/g, ' ');\n try {\n parsed = JSON.parse(content);\n } catch (e) {\n throw new Error(`Failed to parse JSON: ${content}`);\n }\n}\n\n// Get session_id from previous node\nconst sessionId = $('Prepare Prompt').item.json.session_id;\n\n// Return clean result\nreturn {\n session_id: sessionId,\n text: parsed.text || \"\",\n ticker: parsed.ticker || null\n};"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
720,
0
],
"id": "parse-response",
"name": "Parse Response"
},
{
"parameters": {
"options": {}
},
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.5,
"position": [
960,
0
],
"id": "19950702-5d61-46e0-a30a-a60fa1249c0d",
"name": "Respond to Webhook"
}
],
"connections": {
"Incoming_request": {
"main": [
[
{
"node": "Prepare Prompt",
"type": "main",
"index": 0
}
]
]
},
"Prepare Prompt": {
"main": [
[
{
"node": "Perplexity API",
"type": "main",
"index": 0
}
]
]
},
"Perplexity API": {
"main": [
[
{
"node": "Parse Response",
"type": "main",
"index": 0
}
]
]
},
"Parse Response": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
]
]
}
},
"meta": {
"templateCredsSetupCompleted": true
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
httpBearerAuth
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Perplexity Node. Uses httpRequest. Webhook trigger; 5 nodes.
Source: https://github.com/aryan4184/CandleCodexAI/blob/c84acbe30c5c71278df6fbfa534e0ab19563b618/n8n/perplexity_node.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n template provides enterprise-level version control for your workflows using GitHub integration. Stop losing hours to broken workflows and manual exports – get proper commit history, visual di
This flow creates dummy files for every item added in your *Arrs (Radarr/Sonarr) with the tag .
This workflow acts as a central API gateway for all technical indicator agents in the Binance Spot Market Quant AI system. It listens for incoming webhook requests and dynamically routes them to the c
Sign PDF documents with legally-compliant digital signatures using X.509 certificates. Supports multiple PAdES signature levels (B, T, LT, LTA) with optional visible stamps.
📡 This workflow serves as the central Alpha Vantage API fetcher for Tesla trading indicators, delivering cleaned 20-point JSON outputs for three timeframes: , , and . It is required by the following a