0
点赞
收藏
分享

微信扫一扫

扣子工作流实战1

工作流 JSON

{
  "version": "1.0",
  "name": "标题生成公众号文案(一句一图+作者简介)",
  "description": "输入文章标题,自动生成「一句一图+作者简介」格式图文,同步至公众号后台草稿箱",
  "variables": [
    {
      "key": "title",
      "name": "文章标题",
      "type": "string",
      "required": true,
      "defaultValue": "王小波美句欣赏",
      "description": "需生成图文的核心标题,如「鲁迅经典语录精选」"
    },
    {
      "key": "wechat_appid",
      "name": "公众号APPID",
      "type": "string",
      "required": true,
      "defaultValue": "",
      "description": "公众号「开发→基本配置」中获取的APPID"
    },
    {
      "key": "wechat_appsecret",
      "name": "公众号APPSECRET",
      "type": "string",
      "required": true,
      "defaultValue": "",
      "description": "公众号「开发→基本配置」中获取的APPSECRET(需启用服务器配置)"
    },
    {
      "key": "cover_image_ratio",
      "name": "封面图比例",
      "type": "string",
      "required": false,
      "defaultValue": "900x383",
      "description": "公众号封面图推荐尺寸,默认900x383(首图)、200x200(次图)"
    },
    {
      "key": "sentence_count",
      "name": "句子数量",
      "type": "number",
      "required": false,
      "defaultValue": 5,
      "description": "正文「一句一图」的组数,默认5组(可调整1-8组,避免内容过长)"
    },
    {
      "key": "author_bio_length",
      "name": "作者简介字数",
      "type": "number",
      "required": false,
      "defaultValue": 150,
      "description": "作者简介建议字数,默认150字(符合公众号阅读体验)"
    },
    {
      "key": "image_style",
      "name": "图片风格",
      "type": "string",
      "required": false,
      "defaultValue": "极简水墨风,低饱和度,文字适配留白",
      "description": "文生图的统一风格,确保图文视觉一致性"
    }
  ],
  "nodes": [
    {
      "id": "start",
      "type": "start",
      "name": "开始节点",
      "outputs": ["out"],
      "config": {
        "inputParams": [
          {"key": "title", "name": "文章标题", "required": true},
          {"key": "wechat_appid", "name": "公众号APPID", "required": true},
          {"key": "wechat_appsecret", "name": "公众号APPSECRET", "required": true},
          {"key": "cover_image_ratio", "name": "封面图比例", "required": false},
          {"key": "sentence_count", "name": "句子数量", "required": false},
          {"key": "author_bio_length", "name": "作者简介字数", "required": false},
          {"key": "image_style", "name": "图片风格", "required": false}
        ]
      }
    },
    {
      "id": "llm_generate_content",
      "type": "llm",
      "name": "大模型:生成句子+图提示+作者简介",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "model": "gpt-3.5-turbo",
        "systemPrompt": "你是专业新媒体文案师,需基于标题生成3部分内容:1.正文:{{sentence_count}}组「句子+图片提示词」,每组占1行,格式为「句子内容|图片提示词(需包含{{image_style}}风格)」;2.作者简介:{{author_bio_length}}字内,含作者生卒年、核心身份、代表作;3.封面图提示词:符合{{cover_image_ratio}}尺寸+{{image_style}}风格,贴合标题主题。最终以JSON输出,key为content_list(数组)、author_bio(字符串)、cover_image_prompt(字符串),无多余内容。",
        "userPrompt": "标题:{{title}},请按要求生成内容",
        "outputs": [
          {"key": "content_json", "name": "生成内容JSON", "type": "json"}
        ]
      }
    },
    {
      "id": "text_split_content",
      "type": "textProcess",
      "name": "文本处理:拆分句子与图提示",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "processType": "splitAndMap",
        "inputKey": "content_json.content_list",
        "splitRule": "|",
        "outputMap": [
          {"key": "sentence", "name": "句子内容", "index": 0},
          {"key": "image_prompt", "name": "图片提示词", "index": 1}
        ],
        "outputs": [
          {"key": "content_sections", "name": "句子-图提示数组", "type": "array"}
        ]
      }
    },
    {
      "id": "image_generate_content",
      "type": "imageGenerate",
      "name": "文生图:生成正文图片",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "provider": "ByteArtist",
        "promptKey": "content_sections[*].image_prompt",
        "size": "600x400",
        "outputs": [
          {"key": "content_image_urls", "name": "正文图片URL数组", "type": "array"}
        ]
      }
    },
    {
      "id": "image_generate_cover",
      "type": "imageGenerate",
      "name": "文生图:生成封面图",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "provider": "ByteArtist",
        "promptKey": "content_json.cover_image_prompt",
        "sizeKey": "cover_image_ratio",
        "outputs": [
          {"key": "cover_image_url", "name": "封面图URL", "type": "string"}
        ]
      }
    },
    {
      "id": "wechat_get_token",
      "type": "apiCall",
      "name": "公众号:获取Access Token",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "method": "GET",
        "url": "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={{wechat_appid}}&secret={{wechat_appsecret}}",
        "outputs": [
          {"key": "access_token", "name": "Access Token", "type": "string", "path": "$.access_token"},
          {"key": "token_expires_in", "name": "Token有效期(秒)", "type": "number", "path": "$.expires_in"}
        ]
      }
    },
    {
      "id": "wechat_upload_content_image",
      "type": "apiCall",
      "name": "公众号:上传正文图片到素材库",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "method": "POST",
        "url": "https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token={{access_token}}",
        "headers": {"Content-Type": "application/json"},
        "bodyType": "json",
        "body": "{{#each content_image_urls}} {\"media\": \"{{this}}\"} {{/each}}",
        "outputs": [
          {"key": "content_media_ids", "name": "正文图片MediaID数组", "type": "array", "path": "$[*].url.match(/mmbiz.qpic.cn\\/([^\\/]+)\\//)[1]"}
        ]
      }
    },
    {
      "id": "wechat_upload_cover_image",
      "type": "apiCall",
      "name": "公众号:上传封面图到素材库",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "method": "POST",
        "url": "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={{access_token}}&type=image",
        "headers": {"Content-Type": "application/json"},
        "bodyType": "json",
        "body": {"media": "{{cover_image_url}}"},
        "outputs": [
          {"key": "cover_media_id", "name": "封面图MediaID", "type": "string", "path": "$.media_id"}
        ]
      }
    },
    {
      "id": "text_assemble_html",
      "type": "textProcess",
      "name": "文本处理:组装公众号HTML正文",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "processType": "templateRender",
        "template": "<div style=\"font-family:Microsoft YaHei, sans-serif; line-height:1.8; color:#333; padding:0 15px;\">\n  {{#each content_sections}}\n    <p style=\"margin:25px 0; font-size:16px;\">{{this.sentence}}</p>\n    <img src=\"https://mmbiz.qpic.cn/mmbiz_jpg/{{content_media_ids @index}}/0\" style=\"width:100%; height:auto; border-radius:8px; margin:10px 0;\" />\n  {{/each}}\n  <div style=\"margin-top:40px; padding-top:20px; border-top:1px dashed #eee;\">\n    <p style=\"font-size:14px; color:#666;\"><strong>作者简介:</strong>{{content_json.author_bio}}</p>\n  </div>\n</div>",
        "outputs": [
          {"key": "final_content_html", "name": "最终HTML正文", "type": "string"}
        ]
      }
    },
    {
      "id": "wechat_create_draft",
      "type": "apiCall",
      "name": "公众号:生成草稿箱文章",
      "inputs": ["in"],
      "outputs": ["out"],
      "config": {
        "method": "POST",
        "url": "https://api.weixin.qq.com/cgi-bin/draft/add?access_token={{access_token}}",
        "headers": {"Content-Type": "application/json"},
        "bodyType": "json",
        "body": {
          "articles": [
            {
              "title": "{{title}}",
              "thumb_media_id": "{{cover_media_id}}",
              "author": "自动生成",
              "digest": "{{content_json.author_bio.substr(0,50)}}...",
              "show_cover_pic": 1,
              "content": "{{final_content_html}}",
              "content_source_url": "",
              "need_open_comment": 0,
              "only_fans_can_comment": 0
            }
          ]
        },
        "outputs": [
          {"key": "draft_id", "name": "草稿ID", "type": "string", "path": "$.media_id"},
          {"key": "draft_create_time", "name": "草稿创建时间", "type": "number", "path": "$.create_time"}
        ]
      }
    },
    {
      "id": "end",
      "type": "end",
      "name": "结束节点",
      "inputs": ["in"],
      "outputs": [],
      "config": {
        "outputParams": [
          {"key": "draft_id", "name": "公众号草稿ID"},
          {"key": "title", "name": "文章标题"},
          {"key": "draft_create_time", "name": "草稿创建时间"}
        ]
      }
    }
  ],
  "connections": [
    {"from": "start.out", "to": "llm_generate_content.in"},
    {"from": "llm_generate_content.out", "to": "text_split_content.in"},
    {"from": "text_split_content.out", "to": "image_generate_content.in"},
    {"from": "llm_generate_content.out", "to": "image_generate_cover.in"},
    {"from": "start.out", "to": "wechat_get_token.in"},
    {"from": "image_generate_content.out", "to": "wechat_upload_content_image.in"},
    {"from": "wechat_get_token.out", "to": "wechat_upload_content_image.in"},
    {"from": "image_generate_cover.out", "to": "wechat_upload_cover_image.in"},
    {"from": "wechat_get_token.out", "to": "wechat_upload_cover_image.in"},
    {"from": "text_split_content.out", "to": "text_assemble_html.in"},
    {"from": "wechat_upload_content_image.out", "to": "text_assemble_html.in"},
    {"from": "llm_generate_content.out", "to": "text_assemble_html.in"},
    {"from": "text_assemble_html.out", "to": "wechat_create_draft.in"},
    {"from": "wechat_get_token.out", "to": "wechat_create_draft.in"},
    {"from": "wechat_upload_cover_image.out", "to": "wechat_create_draft.in"},
    {"from": "wechat_create_draft.out", "to": "end.in"}
  ]
}

保存为josn文件后,打包压缩为zip后,上传到扣子使用!

举报

相关推荐

0 条评论