AutomationFlowsEmail & Gmail › Generate AI Responses with Perplexity Sonar Models (reusable Module)

Generate AI Responses with Perplexity Sonar Models (reusable Module)

ByAleksey Panov @ampanov on n8n.io

This reusable workflow allows you to interact with the Perplexity API using the or models. It is designed to be triggered from other workflows and accepts dynamic prompts via input parameters. 🧱 Modular: Triggered using from any other workflow 📥 Inputs: : Set your system-level…

Event trigger★★☆☆☆ complexity6 nodesExecute Workflow TriggerHTTP Request
Email & Gmail Trigger: Event Nodes: 6 Complexity: ★★☆☆☆ Added:

This workflow corresponds to n8n.io template #4978 — we link there as the canonical source.

This workflow follows the Execute Workflow Trigger → HTTP Request recipe pattern — see all workflows that pair these two integrations.

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 →

Download .json
{
  "id": "YUOkKLDiARiuwpTP",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Perplexity(sonar) for publication",
  "tags": [],
  "nodes": [
    {
      "id": "33f3c51d-45f0-4c2b-9981-a413ae50772e",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -520
      ],
      "parameters": {
        "color": 4,
        "width": 980,
        "height": 240,
        "content": "## \ud83d\udd0d Perplexity API Integration\n\nThis workflow sends a request to Perplexity\u2019s chat completion API using the `sonar` or `sonar-pro` model.\n\n\u27a1\ufe0f Triggered via \"Execute Workflow\"  \n\ud83d\udce4 Accepts dynamic `SystemPrompt` and `UserPrompt`  \n\ud83d\udd10 Supports Header Auth\n\n\ud83d\udcd8 [API Docs](https://docs.perplexity.ai/api-reference/async-chat-completions-post)"
      },
      "typeVersion": 1
    },
    {
      "id": "19797db1-b7bb-47c9-b13f-983639639309",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "SystemPrompt"
            },
            {
              "name": "UserPrompt"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "58674959-f4bb-4bae-a6cd-600059072b6b",
      "name": "Parameters",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        0
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "18e5ccd4-5538-4ace-9957-00a2c0c43518",
              "name": "model",
              "type": "string",
              "value": "sonar"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "cf181e63-9a9b-4ab0-a4cf-cf8e8ceba85f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -260
      ],
      "parameters": {
        "width": 330,
        "height": 240,
        "content": "## \ud83e\udde0 Supported Models\n\n- `sonar`\n- `sonar-pro`\n\n\ud83d\udcd8 [Model cards and capabilities](https://docs.perplexity.ai/models/model-cards)\n\nTo switch models, change the `\"model\"` value in the **Parameters** node."
      },
      "typeVersion": 1
    },
    {
      "id": "aed49866-4b61-4170-aafb-7c70b2312a3a",
      "name": "Perplexity API Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        460,
        0
      ],
      "parameters": {
        "url": "https://api.perplexity.ai/chat/completions",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"{{$('Parameters').item.json.model}}\",\n  \"messages\": [\n    {\n      \"role\": \"system\",\n      \"content\": \"{{ $('When Executed by Another Workflow').item.json.SystemPrompt }}\"\n    },\n    {\n      \"role\": \"user\",\n      \"content\": \"{{ $('When Executed by Another Workflow').item.json.UserPrompt }}\"\n    }\n  ]\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "typeVersion": 4.2
    },
    {
      "id": "0ae885d9-e8bf-4974-9741-46875836e6d7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -420,
        -260
      ],
      "parameters": {
        "width": 380,
        "height": 460,
        "content": "## \ud83e\udde9 Input Parameters\n\nThis workflow expects **two inputs** when triggered from another workflow:\n\n- `SystemPrompt` \ud83e\udde0  \n  \u2192 Sets the system message (e.g., behavior or tone) for the LLM.\n\n- `UserPrompt` \ud83d\udcac  \n  \u2192 The main user question or instruction for the model.\n\n\ud83d\udccc These inputs are used to construct the `messages` array for the Perplexity API.\n\nYou can pass them via the \u201cExecute Workflow\u201d node in your parent workflow."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "a1639271-f212-461b-b661-b0ecad7e9ebb",
  "connections": {
    "Parameters": {
      "main": [
        [
          {
            "node": "Perplexity API Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perplexity API Request": {
      "main": [
        []
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Parameters",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This reusable workflow allows you to interact with the Perplexity API using the or models. It is designed to be triggered from other workflows and accepts dynamic prompts via input parameters. 🧱 Modular: Triggered using from any other workflow 📥 Inputs: : Set your system-level…

Source: https://n8n.io/workflows/4978/ — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Email & Gmail

get_a_web_page. Uses executeWorkflowTrigger, httpRequest, stickyNote. Event-driven trigger; 4 nodes.

Execute Workflow Trigger, HTTP Request
Email & Gmail

Splitout Code. Uses manualTrigger, httpRequest, stickyNote, splitOut. Event-driven trigger; 46 nodes.

HTTP Request, Execute Workflow Trigger, Gmail +1
Email & Gmail

Automate CSV imports into HubSpot without the mess. Powered by n8n. Supercharged by Pollup AI.

HTTP Request, Execute Workflow Trigger, Gmail +1
Email & Gmail

Echo Brand Voice Analysis (Processor) - TASK-074 Dec 10 Fix. Uses formTrigger, httpRequest, executeWorkflowTrigger, moveBinaryData. Event-driven trigger; 40 nodes.

Form Trigger, HTTP Request, Execute Workflow Trigger +2
Email & Gmail

Splitout Googlecalendar. Uses gmail, googleCalendar, lmChatOpenAi, informationExtractor. Event-driven trigger; 61 nodes.

Gmail, Google Calendar, OpenAI Chat +5