AutomationFlowsAI & RAG › Research-to-social Post Generator with Perplexity AI and Facebook Graph API

Research-to-social Post Generator with Perplexity AI and Facebook Graph API

ByHoangSP @hoangsp on n8n.io

Teams that want to turn a chat prompt into a researched, ready-to-post social update—optionally published to Facebook. Chat Trigger receives the user prompt Topic Agent optionally calls a research sub-workflow for fresh sources Outputs are validated into a structured JSON Post…

Chat trigger trigger★★★★☆ complexityAI-powered25 nodesChat TriggerTool WorkflowAgentOutput Parser StructuredOpenAI ChatFacebook Graph Api
AI & RAG Trigger: Chat trigger Nodes: 25 Complexity: ★★★★☆ AI nodes: yes Added:
Research-to-social Post Generator with Perplexity AI and Facebook Graph API — n8n workflow card showing Chat Trigger, Tool Workflow, Agent integration

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

This workflow follows the Agent → Chat Trigger 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": "N2Pc8CYYmgYeCihm",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Chatbot Content Agent",
  "tags": [],
  "nodes": [
    {
      "id": "71fa822b-c898-4ff6-ad65-175ead2a5a33",
      "name": "Chat Trigger",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -416,
        80
      ],
      "parameters": {
        "public": true,
        "options": {},
        "initialMessages": "Hi there! \ud83d\udc4b\nI'm your Content Assistant. I can research with Perplexity and draft posts for you.\nHow can I help today?"
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    },
    {
      "id": "69fdd569-4d6d-4d21-aac7-5ea3c00ad7f1",
      "name": "Tool: Call Perplexity Researcher",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        64,
        304
      ],
      "parameters": {
        "name": "Perplexity_Research_Tool",
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": ""
        },
        "description": "{{ new Date().toISOString() }}\nCall this tool to perform Perplexity research.\nIt finds the latest, high-quality sources for the user's topic to support content drafting.\nNOTE: Link your own Research workflow (set `workflowId`) before running.\n",
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "3a2f2d0c-f3bf-47c7-b1bb-ad9870a7f0ca",
      "name": "Agent: Topic + Research",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -144,
        80
      ],
      "parameters": {
        "text": "={{$now}}\nPh\u00e2n t\u00edch t\u1ef1 \u0111\u1ec1\n{{ $json.chatInput }}",
        "options": {
          "systemMessage": "User the perplexity_research_too, to provide research on the users topic"
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "d399f15d-6d71-4a91-a333-3d24ba8f8b2d",
      "name": "Parser: Article JSON",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        432,
        288
      ],
      "parameters": {
        "schemaType": "manual",
        "inputSchema": "{\n  \"type\": \"object\",\n  \"properties\": {\n    \"article\": {\n      \"type\": \"object\",\n      \"required\": [\"title\", \"subtitle\", \"content\", \"hashtags\"],\n      \"properties\": {\n        \"title\": {\n          \"type\": \"string\",\n          \"description\": \"Article title\"\n        },\n        \"subtitle\": {\n          \"type\": \"string\",\n          \"description\": \"Article subtitle\"\n        },\n        \"content\": {\n          \"type\": \"object\",\n          \"properties\": {\n            \"mainText\": {\n              \"type\": \"string\",\n              \"description\": \"Main article content\"\n            },\n            \"sections\": {\n              \"type\": \"array\",\n              \"items\": {\n                \"type\": \"object\",\n                \"properties\": {\n                  \"title\": {\n                    \"type\": \"string\",\n                    \"description\": \"Section title\"\n                  },\n                  \"text\": {\n                    \"type\": \"string\",\n                    \"description\": \"Section content\"\n                  },\n                  \"quote\": {\n                    \"type\": \"string\",\n                    \"description\": \"Blockquote text\"\n                  }\n                },\n                \"required\": [\"title\", \"text\", \"quote\"]\n              }\n            }\n          },\n          \"required\": [\"mainText\", \"sections\"]\n        },\n        \"hashtags\": {\n          \"type\": \"array\",\n          \"items\": {\n            \"type\": \"string\"\n          },\n          \"description\": \"Article hashtags\"\n        }\n      }\n    }\n  }\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "376491c5-e9e4-4eed-837c-fc751ea846d0",
      "name": "LM: For Topic Agent",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -176,
        288
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini",
          "cachedResultName": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "f25ea7f9-ccf4-4b70-9fad-e0f373f97cca",
      "name": "LM: For JSON Extraction",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        272,
        288
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o",
          "cachedResultName": "gpt-4o"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "eef73ee5-3efb-46ac-8d7a-f66301748a05",
      "name": "Agent: Extract JSON",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        272,
        80
      ],
      "parameters": {
        "text": "=Extract a JSON object from this content:{{ $json.output }}  and also fill this fields that is missing (exclude quote)\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "5628d8ff-0381-4703-b8c3-dfa972eeded6",
      "name": "Parser: Post Fields",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1024,
        32
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"title\": \"The headline for the social media post\",\n  \"subtitle\": \"The subtitle of the social post that I can put onto the poster\",\n  \"content\": \"The formatted social media post\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "309a55bc-250c-40e6-812d-5adae1aa411d",
      "name": "LM: For Post Writer",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        800,
        32
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "a459abd4-6193-473b-aa06-5f02cdf137ba",
      "name": "Agent: Create Post Content",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        800,
        -176
      ],
      "parameters": {
        "text": "=Convert this JSON into a concise and engaging blog in Vietnamese Language: {{$json.output.article.toJsonString() }}\n\n## Formatting Guidelines\n- Write posts in a clear, natural tone\n- Use the title of the post as the opening line or focus.\n- Use emojis to highlight key ideas, e.g. \ud83c\udf3a , l\ud83d\udd25 , \ud83d\udce3,\n- Keep content short and sweet, don't translate every word, but make sure the meaning flows and is easy to read.\n- Add compelling calls to action (CTA) such as: \u201cSee more now!\u201d, \u201cWhat do you think? Comment! \ud83d\ude80\u201d.\n- Use hashtags from the \u201chashtags\u201d field in JSON to increase accessibility\n- Quotes or key ideas should be emphasized with quotation marks: \u201c\u2026\u201d or add emoji: \ud83d\udcac .\n- Avoid long sentences; keep the post easy to understand.\n- Make sure Vietnamese spelling and grammar are correct\n- Please do not use symbols such as ** or *",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.8
    },
    {
      "id": "15c2b1b8-10f6-4c63-a790-9caf41337734",
      "name": "Publish: Facebook Graph API",
      "type": "n8n-nodes-base.facebookGraphApi",
      "position": [
        1360,
        -176
      ],
      "parameters": {
        "edge": "feed",
        "node": "YOUR_FACEBOOK_PAGE_ID",
        "options": {
          "queryParameters": {
            "parameter": [
              {
                "name": "message",
                "value": "={{ $json.output }}.replaceall(\"*\",\"\")\n"
              }
            ]
          }
        },
        "graphApiVersion": "v22.0",
        "httpRequestMethod": "POST"
      },
      "typeVersion": 1
    },
    {
      "id": "6d051ca3-731a-4527-82b2-fab006a48c6f",
      "name": "\u2699\ufe0f CONFIG (Set fields)",
      "type": "n8n-nodes-base.set",
      "position": [
        -760,
        -200
      ],
      "parameters": {
        "fields": {
          "values": [
            {
              "name": "FACEBOOK_PAGE_ID",
              "stringValue": "YOUR_FACEBOOK_PAGE_ID"
            },
            {
              "name": "FACEBOOK_EDGE",
              "stringValue": "feed"
            },
            {
              "name": "RESEARCH_WORKFLOW_ID",
              "stringValue": "YOUR_RESEARCH_WORKFLOW_ID"
            },
            {
              "name": "POST_EMOJI_STYLE",
              "stringValue": "\ud83d\udd25 \ud83d\ude80 \ud83d\udcac"
            },
            {
              "name": "LANGUAGE",
              "stringValue": "vi-VN"
            }
          ]
        },
        "include": "none",
        "options": {}
      },
      "typeVersion": 3.4
    },
    {
      "id": "5a0344d3-386b-4a0b-b1bc-cd5927a25ac0",
      "name": "Sticky: Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        -420
      ],
      "parameters": {
        "color": 2,
        "width": 720,
        "height": 540,
        "content": "## Who\u2019s it for\nMarketers, founders, and content teams who want to turn ideas from a chat into polished social posts\u2014grounded in quick research and published to Facebook in one flow.\n\n## What it does / How it works\n1) **Chat Trigger** receives a prompt.  \n2) **Agent: Topic + Research** may call **Tool: Call Perplexity Researcher** for up-to-date sources.  \n3) The output is parsed into a structured **Article JSON**.  \n4) **Agent: Create Post Content** turns it into a concise Vietnamese post.  \n5) **Publish: Facebook Graph API** posts to your Page (optional).\n\n## How to set up\n- Open **Credentials** and connect OpenAI & Facebook (no API keys inside nodes).  \n- In **Tool: Call Perplexity Researcher**, set your `RESEARCH_WORKFLOW_ID`.  \n- In **Publish: Facebook Graph API**, set `YOUR_FACEBOOK_PAGE_ID` and the correct `edge` (`feed`).  \n- (Optional) Adjust tone/language in **CONFIG** and prompt nodes.\n\n## Requirements\n- n8n (Cloud or self-hosted)  \n- OpenAI API key stored in **Credentials**  \n- Facebook Page access with publish permissions  \n- (Optional) A research sub-workflow to plug in\n\n## How to customize\n- Add branches for platforms (e.g., LinkedIn/Twitter) or content variants.  \n- Swap models or tune prompts to match brand tone.  \n- Store outputs into Google Sheets, Notion, or a database.  \n- Add moderation or review step before auto-posting.\n\n## Security\n- Do **not** hardcode credentials in HTTP or Code nodes.  \n- Keep Page IDs and workflow IDs configurable.  \n- If sharing publicly, remove private identifiers and example credentials.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e78a233a-5e1e-4091-9ab9-ff0d40bdcb22",
      "name": "Sticky: Chat Trigger",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -196,
        40
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Chat Trigger\nReceives the user prompt from the chat. Keep the greeting simple. You can add quick-help text or examples here.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7f547b8b-ff5f-4fcb-a9ac-7f96b700103b",
      "name": "Sticky: Agent: Topic + Research",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        76,
        40
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Agent: Topic + Research\nDrafts a topic brief. It can call the research tool for sources.\nPrompt tip: Keep instructions short; tell the agent when to call research.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2179ad75-830c-472a-af6e-3a1044817885",
      "name": "Sticky: Tool: Call Perplexity Researcher",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        284,
        264
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Tool: Call Perplexity Researcher\nBefore running, set the `workflowId` to your research sub-workflow.\nExpected output: a concise list of sources & takeaways.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9e6152da-84fd-46a7-bff8-dcd0a404f618",
      "name": "Sticky: Parser: Article JSON",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        652,
        248
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Parser: Article JSON\nValidates & structures the article (title, subtitle, content, hashtags).\nIf fields are missing, upstream agent should fill them first.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f0bc973b-506b-45ee-86f1-96b3bda1e823",
      "name": "Sticky: Agent: Extract JSON",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        492,
        40
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Agent: Extract JSON\nExtracts a valid JSON object from the previous output.\nKeep instructions declarative (what to output, not how).\n"
      },
      "typeVersion": 1
    },
    {
      "id": "64905994-b151-4b83-bf76-ec15fff86e80",
      "name": "Sticky: Parser: Post Fields",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1244,
        -8
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Parser: Post Fields\nDefines final fields for the post: title, subtitle, content.\nDownstream agent formats the final Vietnamese copy.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "cea84b3d-fa70-485c-82d9-82a026d26000",
      "name": "Sticky: Agent: Create Post Content",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1020,
        -216
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Agent: Create Post Content\nTurns the structured article into a concise Vietnamese social post with emojis & CTA.\nAdjust tone and style in the prompt block here.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7d623d22-70f2-428e-80fc-d5998292308a",
      "name": "Sticky: LM: For Topic Agent",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        44,
        248
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## LM for Topic Agent\nOpenAI model used by the Topic agent. Configure via Credentials, not in-node keys.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a09e5aba-19fa-4067-b238-eacd4911b38d",
      "name": "Sticky: LM: For JSON Extraction",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        492,
        248
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## LM for JSON Extraction\nOpenAI model used by the JSON extraction agent. Tune temperature if needed.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1934213e-efbe-43a5-b1a7-b0c8327f568d",
      "name": "Sticky: LM: For Post Writer",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1020,
        -8
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## LM for Post Writer\nOpenAI model used by the post-writing agent. Set a lower temperature for consistency.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "35a55b97-1b2f-475a-b82f-4fc848bfcae1",
      "name": "Sticky: Publish: Facebook Graph API",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1580,
        -216
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 180,
        "content": "## Publish: Facebook Graph API\nSet `YOUR_FACEBOOK_PAGE_ID` and select the `feed` edge.\nKeep this disabled during testing, or route into a review step first.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "ae438cec-a8a7-4ce9-b5f9-6033ee75ba13",
      "name": "Sticky: Template Checklist",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1160,
        220
      ],
      "parameters": {
        "color": 4,
        "width": 480,
        "height": 220,
        "content": "## Template Checklist\n- Rename nodes descriptively \u2714\ufe0f\n- Use Sticky Notes: overview + per-step \u2714\ufe0f\n- No hardcoded API keys/IDs in nodes \u2714\ufe0f\n- Add CONFIG Set node \u2714\ufe0f\n- Description written in Markdown with H2 \u2714\ufe0f\n- Ready for submission & reuse \u2714\ufe0f\n"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "settings": {
    "timezone": "Asia/Bangkok",
    "callerPolicy": "workflowsFromSameOwner",
    "executionOrder": "v1"
  },
  "versionId": "ce4b61cd-82e5-4bec-8097-6e61ada3f23c",
  "connections": {
    "Extract Json": {
      "main": [
        [
          {
            "node": "Create Post Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Perplexity Topic": {
      "main": [
        [
          {
            "node": "Extract Json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Post Content": {
      "main": [
        [
          {
            "node": "Facebook Graph API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o-mini2": {
      "ai_languageModel": [
        [
          {
            "node": "Perplexity Topic",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o-mini3": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Json",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-4o-mini4": {
      "ai_languageModel": [
        [
          {
            "node": "Create Post Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Extract Json",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser1": {
      "ai_outputParser": [
        [
          {
            "node": "Create Post Content",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Call Perplexity Researcher": {
      "ai_tool": [
        [
          {
            "node": "Perplexity Topic",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Perplexity Topic",
            "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

Teams that want to turn a chat prompt into a researched, ready-to-post social update—optionally published to Facebook. Chat Trigger receives the user prompt Topic Agent optionally calls a research sub-workflow for fresh sources Outputs are validated into a structured JSON Post…

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

More AI & RAG workflows → · Browse all categories →

Related workflows

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

AI & RAG

by Varritech Technologies

Chat Trigger, Agent, OpenAI Chat +8
AI & RAG

✨📊Multi-AI Agent Chatbot for Postgres/Supabase DB and QuickCharts + Tool Router. Uses chatTrigger, postgresTool, executeWorkflowTrigger, toolWorkflow. Chat trigger; 40 nodes.

Chat Trigger, Postgres Tool, Execute Workflow Trigger +6
AI & RAG

This workflow is ideal for data analysts, developers, and business intelligence teams who need an AI-powered chatbot to query Postgres/Supabase databases and generate dynamic charts for data visualiza

Chat Trigger, Postgres Tool, Execute Workflow Trigger +6
AI & RAG

This Chatbot automates the process of discovering job openings and generating tailored job application emails.

Chat Trigger, OpenAI Chat, Mcp Client Tool +12
AI & RAG

This n8n template provides a powerful AI-powered chatbot that acts as your personal Spotify DJ. Simply tell the chatbot what kind of music you're in the mood for, and it will intelligently create a cu

OpenAI Chat, Spotify, Chain Llm +7