{
  "name": "News",
  "nodes": [
    {
      "parameters": {
        "options": {}
      },
      "id": "10498042-940e-4aa5-b22a-c2a5e6b3958c",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.4,
      "position": [
        0,
        0
      ],
      "webhookId": "RECONNECT_CHAT_TRIGGER"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Search the internet and get the news about the topic provided by the user ({{ $json.chatInput }})\n\nUse the right document formatting and editing when updating the information in the Google docs",
        "options": {
          "systemMessage": "=Role & Purpose\n\nYou are an AI News Research & Distribution Agent. Your purpose is to research the latest news about a specified topic, compile the findings into a professionally formatted document, and distribute both the document and a formatted email summary to the specified recipient. Always prioritize accuracy, recency, and clear presentation.\n\nCapabilities\n\n- Search for the latest and most relevant news related to the requested topic.\n- Gather information from multiple reputable news sources and identify the key developments.\n- Summarize the news into a concise, factual, and well-structured report.\n- Create a professionally formatted document containing the complete report.\n- Format an email-ready version of the report that is easy to read.\n- Send the formatted report and the generated document to the specified email address.\n- Include publication dates and source names for every news item whenever available.\n\n** Tools **\n\n- Web Search – Retrieve the latest news from reputable online sources.\n- Document Generator – Create a formatted document (DOCX or PDF).\n- Email Tool – Send emails with attachments to the specified recipient.\n\nInteraction Style\n\n- Be professional, concise, and factual.\n- Present information using clear headings and bullet points where appropriate.\n- Never speculate or invent information.\n- Always verify that the information is recent before including it.\n\nExample Output\n\nUser Request:\n\"Get the latest news on the economy in Switzerland. Create a document and email it to RECONNECT_RECIPIENT_EMAIL.\"\n\nExpected Workflow:\n\n1. Search for the latest economic news related to Switzerland.\n2. Select the most relevant and recent stories.\n3. Create a report with the following structure:\n\n# Switzerland Economy News Report\nGenerated: {Current Date}\n\n## Executive Summary\nA brief overview of the latest economic developments.\n\n## Latest News\n\n### 1. {Headline}\n- Summary\n- Key impacts\n- Publication Date\n- Source\n\n### 2. {Headline}\n- Summary\n- Key impacts\n- Publication Date\n- Source\n\n(Repeat as necessary.)\n\n## Overall Outlook\nA concise summary of the current economic situation based on the collected news.\n\n4. Save the report as a professionally formatted DOCX (or PDF).\n\n5. Compose an email containing:\n\nSubject:\nLatest Switzerland Economy News Report\n\nBody:\nHello,\n\nPlease find below the latest news regarding the Swiss economy.\n\n{Formatted Executive Summary}\n\nKey Highlights:\n• Highlight 1\n• Highlight 2\n• Highlight 3\n\nThe full report is attached for your reference.\n\nBest regards,\nAI News Research Agent\n\n6. Send the email to:\nRECONNECT_RECIPIENT_EMAIL\n\nwith the generated report attached.\n\n** Notes **\n\n- Always use the most recent available news.\n- Prefer reputable news organizations and official government or financial sources.\n- If multiple sources report the same story, consolidate them into a single summary.\n- If no recent news is available, clearly state this instead of generating information.\n- Ensure the generated document and the email content are consistent.\n- Replace placeholders (topic, email address, dates, and filenames) with the user's requested values before execution."
        }
      },
      "id": "70d9e03b-329f-43e7-973b-8a95b051f464",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        208,
        0
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "value": "gpt-4o-mini",
          "mode": "list",
          "cachedResultName": "gpt-4o-mini"
        },
        "builtInTools": {},
        "options": {}
      },
      "id": "70d92fcf-83ec-4ad8-a2a0-749971fdfde8",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        80,
        208
      ],
      "credentials": {
        "openAiApi": {
          "id": null,
          "name": "",
          "__aiGatewayManaged": true
        }
      }
    },
    {
      "parameters": {
        "descriptionType": "manual",
        "toolDescription": "Create a document in Google Docs",
        "folderId": "default",
        "title": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Title', ``, 'string') }}"
      },
      "id": "a1b33025-8ac3-4eb8-9cfa-bf9a338418b2",
      "name": "createDoc",
      "type": "n8n-nodes-base.googleDocsTool",
      "typeVersion": 2,
      "position": [
        336,
        272
      ],
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "",
          "name": "RECONNECT_GOOGLE_DOCS_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "operation": "update",
        "documentURL": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Doc_ID_or_URL', ``, 'string') }}",
        "actionsUi": {
          "actionFields": [
            {
              "action": "insert",
              "text": "={{ $fromAI('Text_Content', 'The AI-formatted news content to insert into the document body', 'string') }}"
            }
          ]
        }
      },
      "id": "bec14f60-3ed5-4bc5-a446-8fc8b1fac9ad",
      "name": "updateDoc",
      "type": "n8n-nodes-base.googleDocsTool",
      "typeVersion": 2,
      "position": [
        512,
        288
      ],
      "credentials": {
        "googleDocsOAuth2Api": {
          "id": "",
          "name": "RECONNECT_GOOGLE_DOCS_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "toolDescription": "=Searches the Internet about a specific topic provided by the user ({{ $json.chatInput }})",
        "method": "POST",
        "url": "https://api.tavily.com/search",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n\"query\": \"{{ $json.chatInput }}\",\n\"topic\": \"general\",\n\"search_depth\": \"advanced\",\n\"chunks_per_source\": 3,\n\"max_results\": 1,\n\"time_range\": null,\n\"days\": 7,\n\"include_answer\": true,\n\"include_raw_content\": false,\n\"include_images\": false,\n\"include_image_descriptions\": false,\n\"include_domains\": [],\n\"exclude_domains\": []\n}",
        "options": {}
      },
      "id": "fe46889e-ba57-4f64-aa6d-82b567342e70",
      "name": "getNews",
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.4,
      "position": [
        192,
        288
      ],
      "credentials": {
        "httpHeaderAuth": {
          "id": "",
          "name": "RECONNECT_SEARCH_CREDENTIAL"
        }
      }
    },
    {
      "parameters": {
        "sendTo": "=RECONNECT_RECIPIENT_EMAIL",
        "subject": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Subject', ``, 'string') }}",
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {
          "appendAttribution": false
        }
      },
      "type": "n8n-nodes-base.gmailTool",
      "typeVersion": 2.2,
      "position": [
        608,
        48
      ],
      "id": "56b86ff8-6db3-496b-852c-c5805e715404",
      "name": "sendMail",
      "webhookId": "RECONNECT_EMAIL_NODE",
      "credentials": {
        "gmailOAuth2": {
          "id": "",
          "name": "RECONNECT_GMAIL_CREDENTIAL"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "createDoc": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "updateDoc": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "getNews": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "sendMail": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "25a71190-6c0d-4aaa-ab99-19a7e4f330f5",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": ""
  },
  "nodeGroups": [],
  "id": "fSIwp483fNipKGrm",
  "tags": []
}
