使用AI从Telegram创建社交媒体内容
高级
这是一个Other, AI领域的自动化工作流,包含 16 个节点。主要使用 Set, Switch, Telegram, HttpRequest, Agent 等节点,结合人工智能技术实现智能自动化。 使用AI从Telegram创建社交媒体内容
前置要求
- •Telegram Bot Token
- •可能需要目标 API 的认证凭证
- •OpenAI API Key
使用的节点 (16)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "b41148c809c7896d124743d940fc0964703e540af66564ef95e25a4ceea61c77",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "070fd7b4-58ca-4372-a347-6f60f590e20b",
"name": "接收 Telegram 消息",
"type": "n8n-nodes-base.telegramTrigger",
"position": [
40,
140
],
"webhookId": "4e2cd560-ae4e-4ed7-a8ea-984518404e51",
"parameters": {
"updates": [
"message"
],
"additionalFields": {}
},
"credentials": {
"telegramApi": {
"id": "lff3pLERRdQmkmeV",
"name": "Telegram account"
}
},
"typeVersion": 1.1
},
{
"id": "0e0f3a32-fbde-42a9-aa7f-70fda7b05357",
"name": "语音还是文本?",
"type": "n8n-nodes-base.switch",
"position": [
400,
220
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "Audio",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "af30c479-4542-405f-b315-37c50c4e2bef",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.voice.file_id }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Text",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "a3ca8cd4-fbb2-40b5-829a-24724f2fbc85",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "={{ $json.message.text || \"\" }}",
"rightValue": ""
}
]
},
"renameOutput": true
},
{
"outputKey": "Error",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "9bcfdee0-2f09-4037-a7b9-689ef392371d",
"operator": {
"type": "string",
"operation": "exists",
"singleValue": true
},
"leftValue": "error",
"rightValue": ""
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "b01dde88-bede-4500-974f-b2dc203ff841",
"name": "获取语音消息",
"type": "n8n-nodes-base.telegram",
"position": [
760,
120
],
"webhookId": "23645237-4943-4c32-b18c-97c410cc3409",
"parameters": {
"fileId": "={{ $json.message.voice.file_id }}",
"resource": "file"
},
"credentials": {
"telegramApi": {
"id": "lff3pLERRdQmkmeV",
"name": "Telegram account"
}
},
"typeVersion": 1.2
},
{
"id": "fe91414e-3b10-482e-b8dd-d55266828dd7",
"name": "语音转文本",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
980,
120
],
"parameters": {
"options": {},
"resource": "audio",
"operation": "translate"
},
"credentials": {
"openAiApi": {
"id": "uFPD9I4pWJ4xUVf7",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "74549458-fd4d-4824-a561-944f2f536b9b",
"name": "为 LLM 做准备",
"type": "n8n-nodes-base.set",
"position": [
880,
340
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "b324a329-3c49-4f7f-b683-74331b7fe7f8",
"name": "=text",
"type": "string",
"value": "={{$json.message.text}}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "886246ad-7127-462a-a2b2-b4281f369d8b",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-40,
0
],
"parameters": {
"width": 260,
"height": 320,
"content": ""
},
"typeVersion": 1
},
{
"id": "d052bd49-dc23-4ec5-b153-a9eb305f0641",
"name": "便签 3",
"type": "n8n-nodes-base.stickyNote",
"position": [
700,
20
],
"parameters": {
"width": 460,
"height": 260,
"content": "**语音消息从 Telegram 获取,并使用 OpenAI 的 Whisper API 转录为文本。**"
},
"typeVersion": 1
},
{
"id": "156580f1-adf5-43ba-b54d-89b84ca87818",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1460,
320
],
"parameters": {
"text": "={{$json.text}}",
"options": {
"systemMessage": " \n**1. AI Agent Goal Prompt (Overall Task)**\n\n* **Purpose:** To define the agent's overall objective, removing the image creation step.\n\n```\nYou are an AI social media content creator. Your task is to research a given topic using SerpAPI, create engaging and SEO-optimized social media content (800-1000 characters), and generate a detailed image prompt. The content must be factually accurate and engaging. Prioritize factual accuracy and engaging storytelling in your content. The generated image prompt should be detailed and specific enough to be used with an image generation tool like DALL-E or Stable Diffusion.\n```\n\n**2. SerpAPI Tool Prompt (Research Phase)**\n\n* **Purpose:** To instruct the agent on how to use SerpAPI to effectively gather information. (No change from previous version)\n\n```\nUse the SerpAPI tool to research the following topic: [TOPIC]. Focus on identifying key facts, trends, and interesting angles relevant for social media. Extract information from the top search results. Return a summary of the information you found focusing on key data and facts.\n```\n\n* **Explanation:**\n * `[TOPIC]` is a variable that will be replaced with the specific topic.\n * Focuses the agent on extracting key facts and trends rather than just providing a list of results.\n * Limits the scope to the top search results to maintain efficiency.\n\n**3. Social Media Content Creation Prompt**\n\n* **Purpose:** To guide the agent in creating engaging and SEO-friendly content based on the research. (No change from previous version)\n\n```\nBased on the following research summary: [RESEARCH_SUMMARY], create a social media post that is:\n\n* Engaging and attention-grabbing\n* Factually accurate\n* Optimized for SEO (include relevant keywords naturally)\n* Within 800-1000 characters\n* Clearly and concisely written.\n* Avoid jargon and technical terms.\n* Include a call to action.\n\nThe tone should be informative but also enthusiastic and easily understandable.\n```\n\n* **Explanation:**\n * `[RESEARCH_SUMMARY]` will be replaced with the output from the SerpAPI tool.\n * Specific instructions on tone, length, and SEO optimization.\n * Explicitly asks for clear and concise writing, avoiding jargon.\n * Added \"Include a call to action\" to make the content more actionable\n\n**4. Image Generation Prompt (for hypothetical image generation tool)**\n\n* **Purpose:** To create a prompt that generates a detailed and descriptive image prompt for an image generation tool. This prompt should now be the *final output* related to the image.\n\n```\nBased on the following topic: [TOPIC] and social media content: [SOCIAL_MEDIA_CONTENT], generate a detailed image prompt for a photorealistic image that visually represents the topic and complements the content. The image should be:\n\n* Photorealistic and high-quality.\n* Visually appealing and attention-grabbing.\n* Relevant to the topic and content.\n* Appropriate for social media.\n\nThe prompt should be exceptionally detailed and specific, providing precise instructions for an image generation tool like DALL-E or Stable Diffusion. Include details about the subject, setting, style, lighting, camera angles, and any other relevant visual elements. Aim for a prompt that leaves no room for misinterpretation by the image generation AI. Mention specific artists or photographic styles to emulate if appropriate.\n```\n\n* **Explanation:**\n * `[TOPIC]` and `[SOCIAL_MEDIA_CONTENT]` are variables that will be replaced with the topic and the created social media content, respectively.\n * Focuses on *photorealism*, relevance, and visual appeal.\n * Emphasizes the need for an *exceptionally detailed and specific* prompt for the image generation tool.\n * Explicitly mentions DALL-E and Stable Diffusion as target tools.\n * Advises the inclusion of artist styles or photographic techniques to guide the image generation.\n\n**5. JSON Output Instruction**\n\n* **Purpose:** To ensure the AI agent provides the output in the correct format. The `image_url` field is replaced with `image_prompt`.\n\n```\nAfter generating the social media content and the image prompt, output the results in the following JSON format:\n\n```json\n{\n\"content\": \"[SOCIAL_MEDIA_CONTENT]\",\n\"image_prompt\": \"[IMAGE_PROMPT]\"\n}\n```\n\n`[SOCIAL_MEDIA_CONTENT]` is the social media content you created.\n`[IMAGE_PROMPT]` is the detailed image prompt you generated.\n```\n\n**Example Usage:**\n\nLet's say the topic is still \"The Benefits of Regular Exercise.\"\n\n1. **SerpAPI Tool:** The agent uses SerpAPI to find information about the benefits of exercise.\n2. **Social Media Content:** The agent generates content like: \"Boost your mood & health! 💪 Regular exercise reduces stress, improves sleep, and lowers disease risk. Get moving today! #exercise #healthylifestyle #fitness\"\n3. **Image Prompt:** The agent generates an image prompt like: \"A photorealistic image of a diverse group of people happily participating in various forms of exercise in a vibrant outdoor setting. Some are jogging in a park with lush green trees, others are doing yoga poses on a grassy field, and a few are cycling on a paved path. The lighting is warm and golden, as if it's early morning or late afternoon. The style should be reminiscent of a National Geographic photograph, emphasizing the natural beauty of the scene and the healthy glow of the people. Use a shallow depth of field to blur the background slightly, drawing focus to the subjects. Camera angle: slightly low, capturing the energy and movement of the scene. Consider influences from the photographic style of Steve McCurry.\"\n4. **JSON Output:**\n\n```json\n{\n\"content\": \"Boost your mood & health! 💪 Regular exercise reduces stress, improves sleep, and lowers disease risk. Get moving today! #exercise #healthylifestyle #fitness\",\n\"image_prompt\": \"A photorealistic image of a diverse group of people happily participating in various forms of exercise in a vibrant outdoor setting. Some are jogging in a park with lush green trees, others are doing yoga poses on a grassy field, and a few are cycling on a paved path. The lighting is warm and golden, as if it's early morning or late afternoon. The style should be reminiscent of a National Geographic photograph, emphasizing the natural beauty of the scene and the healthy glow of the people. Use a shallow depth of field to blur the background slightly, drawing focus to the subjects. Camera angle: slightly low, capturing the energy and movement of the scene. Consider influences from the photographic style of Steve McCurry.\"\n}\n```\n\n**Key Improvements and Techniques Used (Beyond the Previous Version):**\n\n* **Focus on Photorealism:** The image prompt now explicitly aims for photorealistic results.\n* **Detailed Image Prompting:** The prompt emphasizes extreme detail and specificity in the image prompt.\n* **Tool Agnostic:** The prompt mentions DALL-E and Stable Diffusion as example tools, but is designed to be usable with other image generation AIs.\n* **Artist Style Guidance:** The prompt encourages the inclusion of artist or photographic style references.\n\n \n"
},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.7
},
{
"id": "74f99543-d7e6-4d9b-8af1-9d86e0566ddc",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
1460,
560
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "uFPD9I4pWJ4xUVf7",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "62b9bb5f-0c87-4df4-ac1c-70b96a0a5cc4",
"name": "SerpAPI",
"type": "@n8n/n8n-nodes-langchain.toolSerpApi",
"position": [
1580,
560
],
"parameters": {
"options": {}
},
"credentials": {
"serpApi": {
"id": "AuYW6wcagKBXR214",
"name": "SerpAPI account"
}
},
"typeVersion": 1
},
{
"id": "3782a100-3210-4c87-9e6a-5808cd488601",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
1700,
560
],
"parameters": {
"jsonSchemaExample": "{\n\"content\": \"[SOCIAL_MEDIA_CONTENT]\",\n\"image_prompt\": \"[IMAGE_PROMPT]\"\n}"
},
"typeVersion": 1.2
},
{
"id": "87bf4b00-4f75-4098-993b-b4bd168339c2",
"name": "从文件提取",
"type": "n8n-nodes-base.extractFromFile",
"position": [
2380,
320
],
"parameters": {
"options": {},
"operation": "binaryToPropery"
},
"typeVersion": 1
},
{
"id": "9a273f0b-bcb0-4ed8-93f5-6161d192e3ef",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1460,
160
],
"parameters": {
"width": 280,
"height": 140,
"content": "**AI 代理使用 OpenAI 聊天模型和 SerpAPI 工具进行研究,并根据用户请求生成社交媒体内容和图像提示。**"
},
"typeVersion": 1
},
{
"id": "c907aa15-1ccf-475e-94da-3a81e54b3746",
"name": "准备最终输出",
"type": "n8n-nodes-base.set",
"position": [
2740,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "df5eb034-ef40-44a3-a620-48981efd1a69",
"name": "content",
"type": "string",
"value": "={{ $('AI Agent').item.json.output.content }}"
},
{
"id": "9ed8afc9-a957-4aea-8554-8c67017ef0e6",
"name": "image",
"type": "string",
"value": "={{ $json.data }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "0893eac1-e72b-4a95-8c3c-4803aaaed9b9",
"name": "生成图片",
"type": "n8n-nodes-base.httpRequest",
"position": [
2020,
320
],
"parameters": {
"url": "https://router.huggingface.co/hf-inference/models/stabilityai/stable-diffusion-3.5-large",
"method": "POST",
"options": {},
"sendBody": true,
"authentication": "predefinedCredentialType",
"bodyParameters": {
"parameters": [
{
"name": "inputs",
"value": "={{ $json.output.image_prompt }}"
}
]
},
"nodeCredentialType": "huggingFaceApi"
},
"credentials": {
"httpHeaderAuth": {
"id": "ERi7DgDYlifAQg7i",
"name": "Header Auth account"
},
"huggingFaceApi": {
"id": "2koOz09ZdzCYUNif",
"name": "HuggingFaceApi account"
}
},
"typeVersion": 4.2
},
{
"id": "b99a090f-73de-4703-b569-8992df36132f",
"name": "便签 1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1960,
240
],
"parameters": {
"width": 220,
"height": 240,
"content": "**使用图像提示生成图像**"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"SerpAPI": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[
{
"node": "Generate Image",
"type": "main",
"index": 0
}
]
]
},
"Generate Image": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Voice or Text?": {
"main": [
[
{
"node": "Fetch Voice Message",
"type": "main",
"index": 0
}
],
[
{
"node": "Prepare for LLM",
"type": "main",
"index": 0
}
]
]
},
"Prepare for LLM": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Prepare Final Output",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Fetch Voice Message": {
"main": [
[
{
"node": "Transcribe Voice to Text",
"type": "main",
"index": 0
}
]
]
},
"Prepare Final Output": {
"main": [
[]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Transcribe Voice to Text": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Receive Telegram Messages": {
"main": [
[
{
"node": "Voice or Text?",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 其他, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
音乐生成工作流
使用 Suno API、Flux、Runway 和 Creatomate 生成 AI 歌曲和音乐视频
Set
Wait
Merge
+16
60 节点Joseph
其他
构建与销售AI自动化与智能体
构建与销售AI自动化与智能体
If
Set
Wait
+15
74 节点NICKYAI
其他
轻松任务管理:从Telegram直接创建Todoist任务
轻松任务管理:通过AI从Telegram直接创建Todoist任务
Set
Switch
Todoist
+7
13 节点Onur
人工智能
商务旅行AI助手 - AI驱动的旅行助理
旅行AI代理 - AI驱动的旅行规划器
Set
Switch
Telegram
+10
16 节点Badr
其他
AI 代理餐厅 [模板]
🤖 WhatsApp、Instagram 和 Messenger 的 AI 餐厅助手
If
N8n
Set
+37
239 节点Amanda Benks
其他
个人 - 申请 TRM
通过 Telegram 机器人和 AI 日期识别获取哥伦比亚比索兑美元汇率
If
Set
Code
+16
31 节点Juan Sanchez
财务
工作流信息
难度等级
高级
节点数量16
分类2
节点类型12
作者
Onur
@onurpolat05Hello, I'm Onur I've been working as a freelance software developer for about four years. In addition, I develop my own projects. For some time, I have been improving myself and providing various services related to AI and AI workflows. Both by writing low code and code. If you have any questions, don't hesitate to contact me.
外部链接
在 n8n.io 查看 →
分享此工作流