app:
  description: '接收销售日志内容，AI 提取客户画像特征（痛点/偏好/购买意向），通过 HTTP 回写至 ERP 客户表的 ai_persona 字段'
  icon: "\U0001F4DD"
  icon_background: '#E4FBCC'
  mode: workflow
  name: '销售日志 → 客户画像提取'
  use_icon_as_answer_icon: false
kind: app
version: 0.1.3
workflow:
  conversation_variables: []
  environment_variables: []
  features:
    file_upload:
      image:
        enabled: false
    opening_statement: ''
    retriever_resource:
      enabled: false
    sensitive_word_avoidance:
      enabled: false
    suggested_questions: []
    suggested_questions_after_answer:
      enabled: false
    text_to_speech:
      enabled: false
  graph:
    edges:
      - data:
          sourceType: start
          targetType: llm
        id: edge-start-to-llm
        source: start
        target: llm-extract
        type: custom
      - data:
          sourceType: llm
          targetType: http-request
        id: edge-llm-to-http
        source: llm-extract
        target: http-update-persona
        type: custom
      - data:
          sourceType: http-request
          targetType: end
        id: edge-http-to-end
        source: http-update-persona
        target: end
        type: custom
    nodes:
      # ── 开始节点 ──
      - data:
          desc: '接收销售日志参数'
          title: 开始
          type: start
          variables:
            - label: customer_id
              max_length: 100
              required: true
              type: text-input
              variable: customer_id
            - label: content
              max_length: 5000
              required: true
              type: paragraph
              variable: content
            - label: salesperson_name
              max_length: 50
              required: false
              type: text-input
              variable: salesperson_name
        height: 90
        id: start
        position:
          x: 80
          y: 282
        type: start
        width: 244

      # ── LLM 画像提取节点 ──
      - data:
          desc: '从销售日志中提取客户画像特征'
          # ⚠️ 导入后请在此节点选择你 Dify 中已配置的模型
          # 推荐选择 Qwen3.5-27B (R740-A 节点)
          model:
            completion_params:
              temperature: 0.3
              max_tokens: 1024
            mode: chat
            name: qwen3.5  # ← 导入后改为你实际的模型名称
            provider: ollama  # ← 改为你的模型供应商
          prompt_template:
            - role: system
              text: |
                你是一名 B2B 润滑油行业的客户分析专家。
                根据销售人员的日志内容，提取客户特征并输出严格的 JSON 格式。

                输出要求（纯 JSON，不要 markdown 代码块）：
                {
                  "pain_points": ["痛点1", "痛点2"],
                  "preferences": ["偏好1", "偏好2"],
                  "purchase_intent": "high 或 medium 或 low",
                  "key_decision_makers": ["决策人姓名"],
                  "competitor_info": ["竞品信息"],
                  "summary": "一句话总结本次跟进要点"
                }

                如果某个字段从日志中无法提取，返回空数组 [] 或 "unknown"。
            - role: user
              text: |
                销售人员: {{#start.salesperson_name#}}
                日志内容:
                {{#start.content#}}
          title: 'AI 画像提取'
          type: llm
        height: 98
        id: llm-extract
        position:
          x: 380
          y: 282
        type: llm
        width: 244

      # ── HTTP 回写客户画像 ──
      - data:
          desc: '将提取的画像 JSON 写入 ERP 客户表'
          title: '回写客户画像'
          type: http-request
          authorization:
            config:
              api_key: ''  # ← 导入后填写 Bearer token
              header: Authorization
              type: bearer
            type: api-key
          body:
            data: '{{#llm-extract.text#}}'
            type: json
          headers: ''
          method: put
          params: ''
          timeout:
            max_connect_timeout: 10
            max_read_timeout: 30
            max_write_timeout: 30
          # ⚠️ 导入后修改为你的实际 ERP 地址
          url: 'http://192.168.1.100:8000/api/customers/{{#start.customer_id#}}/persona'
        height: 98
        id: http-update-persona
        position:
          x: 680
          y: 282
        type: http-request
        width: 244

      # ── 结束节点 ──
      - data:
          desc: ''
          outputs:
            - value_selector:
                - llm-extract
                - text
              variable: ai_persona_result
            - value_selector:
                - http-update-persona
                - status_code
              variable: http_status
          title: 结束
          type: end
        height: 90
        id: end
        position:
          x: 980
          y: 282
        type: end
        width: 244
  hash: ''
