segment-automation

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Segment Automation via Rube MCP

通过Rube MCP实现Segment自动化

Automate Segment customer data platform operations through Composio's Segment toolkit via Rube MCP.
通过Composio的Segment工具包,借助Rube MCP自动化Segment客户数据平台的操作。

Prerequisites

前提条件

  • Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
  • Active Segment connection via
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    segment
  • Always call
    RUBE_SEARCH_TOOLS
    first to get current tool schemas
  • 必须已连接Rube MCP(需提供RUBE_SEARCH_TOOLS)
  • 通过
    RUBE_MANAGE_CONNECTIONS
    激活Segment连接,工具包为
    segment
  • 请始终先调用
    RUBE_SEARCH_TOOLS
    以获取当前工具架构

Setup

设置步骤

Get Rube MCP: Add
https://rube.app/mcp
as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
  1. Verify Rube MCP is available by confirming
    RUBE_SEARCH_TOOLS
    responds
  2. Call
    RUBE_MANAGE_CONNECTIONS
    with toolkit
    segment
  3. If connection is not ACTIVE, follow the returned auth link to complete Segment authentication
  4. Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加
https://rube.app/mcp
作为MCP服务器。无需API密钥——只需添加端点即可使用。
  1. 确认
    RUBE_SEARCH_TOOLS
    能正常响应,以此验证Rube MCP是否可用
  2. 调用
    RUBE_MANAGE_CONNECTIONS
    ,指定工具包为
    segment
  3. 如果连接未处于ACTIVE状态,请按照返回的认证链接完成Segment身份验证
  4. 在运行任何工作流之前,确认连接状态显示为ACTIVE

Core Workflows

核心工作流

1. Track Events

1. 跟踪事件

When to use: User wants to send event data to Segment for downstream destinations
Tool sequence:
  1. SEGMENT_TRACK
    - Send a single track event [Required]
Key parameters:
  • userId
    : User identifier (required if no
    anonymousId
    )
  • anonymousId
    : Anonymous identifier (required if no
    userId
    )
  • event
    : Event name (e.g., 'Order Completed', 'Button Clicked')
  • properties
    : Object with event-specific properties
  • timestamp
    : ISO 8601 timestamp (optional; defaults to server time)
  • context
    : Object with contextual metadata (IP, user agent, etc.)
Pitfalls:
  • At least one of
    userId
    or
    anonymousId
    is required
  • event
    name is required and should follow consistent naming conventions
  • Properties are freeform objects; ensure consistent schema across events
  • Timestamp must be ISO 8601 format (e.g., '2024-01-15T10:30:00Z')
  • Events are processed asynchronously; successful API response means accepted, not delivered
适用场景:用户需要将事件数据发送至Segment,以供下游目标系统使用
工具流程:
  1. SEGMENT_TRACK
    - 发送单个跟踪事件 [必填]
关键参数:
  • userId
    : 用户标识符(若未提供
    anonymousId
    则为必填)
  • anonymousId
    : 匿名用户标识符(若未提供
    userId
    则为必填)
  • event
    : 事件名称(例如:'Order Completed'、'Button Clicked')
  • properties
    : 包含事件特定属性的对象
  • timestamp
    : ISO 8601格式时间戳(可选;默认使用服务器时间)
  • context
    : 包含上下文元数据的对象(IP、用户代理等)
注意事项:
  • 必须提供
    userId
    anonymousId
    中的至少一个
  • event
    名称为必填项,且应遵循统一的命名规范
  • 属性为自由格式对象;需确保不同事件间的架构一致性
  • 时间戳必须为ISO 8601格式(例如:'2024-01-15T10:30:00Z')
  • 事件为异步处理;API响应成功仅表示事件已被接收,不代表已送达目标系统

2. Identify Users

2. 识别用户

When to use: User wants to associate traits with a user profile in Segment
Tool sequence:
  1. SEGMENT_IDENTIFY
    - Set user traits and identity [Required]
Key parameters:
  • userId
    : User identifier (required if no
    anonymousId
    )
  • anonymousId
    : Anonymous identifier
  • traits
    : Object with user properties (email, name, plan, etc.)
  • timestamp
    : ISO 8601 timestamp
  • context
    : Contextual metadata
Pitfalls:
  • At least one of
    userId
    or
    anonymousId
    is required
  • Traits are merged with existing traits, not replaced
  • To remove a trait, set it to
    null
  • Identify calls should be made before track calls for new users
  • Avoid sending PII in traits unless destinations are configured for it
适用场景:用户需要将用户特征关联至Segment中的用户档案
工具流程:
  1. SEGMENT_IDENTIFY
    - 设置用户特征与身份 [必填]
关键参数:
  • userId
    : 用户标识符(若未提供
    anonymousId
    则为必填)
  • anonymousId
    : 匿名用户标识符
  • traits
    : 包含用户属性的对象(邮箱、姓名、套餐等)
  • timestamp
    : ISO 8601格式时间戳
  • context
    : 上下文元数据
注意事项:
  • 必须提供
    userId
    anonymousId
    中的至少一个
  • 用户特征会与现有特征合并,而非替换
  • 若要删除某个特征,需将其值设为
    null
  • 对于新用户,应先调用IDENTIFY再调用TRACK
  • 除非目标系统已配置支持,否则请勿在特征中发送个人可识别信息(PII)

3. Batch Operations

3. 批量操作

When to use: User wants to send multiple events, identifies, or other calls in a single request
Tool sequence:
  1. SEGMENT_BATCH
    - Send multiple Segment calls in one request [Required]
Key parameters:
  • batch
    : Array of message objects, each with:
    • type
      : Message type ('track', 'identify', 'group', 'page', 'alias')
    • userId
      /
      anonymousId
      : User identifier
    • Additional fields based on type (event, properties, traits, etc.)
Pitfalls:
  • Each message in the batch must have a valid
    type
    field
  • Maximum batch size limit applies; check schema for current limit
  • All messages in a batch are processed independently; one failure does not affect others
  • Each message must independently satisfy its type's requirements (e.g., track needs event name)
  • Batch is the most efficient way to send multiple calls; prefer over individual calls
适用场景:用户需要在单个请求中发送多个事件、识别请求或其他调用
工具流程:
  1. SEGMENT_BATCH
    - 在一个请求中发送多个Segment调用 [必填]
关键参数:
  • batch
    : 消息对象数组,每个对象包含:
    • type
      : 消息类型('track'、'identify'、'group'、'page'、'alias')
    • userId
      /
      anonymousId
      : 用户标识符
    • 基于类型的其他字段(event、properties、traits等)
注意事项:
  • 批量中的每条消息必须包含有效的
    type
    字段
  • 存在最大批量大小限制;请查看架构获取当前限制
  • 批量中的所有消息独立处理;某条消息失败不会影响其他消息
  • 每条消息必须独立满足其类型的要求(例如:track类型需要event名称)
  • 批量操作是发送多个调用的最高效方式;优先使用批量而非单个调用

4. Group Users

4. 用户群组管理

When to use: User wants to associate a user with a company, team, or organization
Tool sequence:
  1. SEGMENT_GROUP
    - Associate user with a group [Required]
Key parameters:
  • userId
    : User identifier (required if no
    anonymousId
    )
  • anonymousId
    : Anonymous identifier
  • groupId
    : Group/organization identifier (required)
  • traits
    : Object with group properties (name, industry, size, plan)
  • timestamp
    : ISO 8601 timestamp
Pitfalls:
  • groupId
    is required; it identifies the company or organization
  • Group traits are merged with existing traits for that group
  • A user can belong to multiple groups
  • Group traits update the group profile, not the user profile
适用场景:用户需要将用户与公司、团队或组织关联
工具流程:
  1. SEGMENT_GROUP
    - 将用户与群组关联 [必填]
关键参数:
  • userId
    : 用户标识符(若未提供
    anonymousId
    则为必填)
  • anonymousId
    : 匿名用户标识符
  • groupId
    : 群组/组织标识符(必填)
  • traits
    : 包含群组属性的对象(名称、行业、规模、套餐)
  • timestamp
    : ISO 8601格式时间戳
注意事项:
  • groupId
    为必填项;用于标识公司或组织
  • 群组特征会与该群组的现有特征合并
  • 一个用户可属于多个群组
  • 群组特征会更新群组档案,而非用户档案

5. Track Page Views

5. 页面浏览跟踪

When to use: User wants to record page view events in Segment
Tool sequence:
  1. SEGMENT_PAGE
    - Send a page view event [Required]
Key parameters:
  • userId
    : User identifier (required if no
    anonymousId
    )
  • anonymousId
    : Anonymous identifier
  • name
    : Page name (e.g., 'Home', 'Pricing', 'Dashboard')
  • category
    : Page category (e.g., 'Docs', 'Marketing')
  • properties
    : Object with page-specific properties (url, title, referrer)
Pitfalls:
  • At least one of
    userId
    or
    anonymousId
    is required
  • name
    and
    category
    are optional but recommended for proper analytics
  • Standard properties include
    url
    ,
    title
    ,
    referrer
    ,
    path
    ,
    search
  • Page calls are often automated; manual use is for server-side page tracking
适用场景:用户需要在Segment中记录页面浏览事件
工具流程:
  1. SEGMENT_PAGE
    - 发送页面浏览事件 [必填]
关键参数:
  • userId
    : 用户标识符(若未提供
    anonymousId
    则为必填)
  • anonymousId
    : 匿名用户标识符
  • name
    : 页面名称(例如:'Home'、'Pricing'、'Dashboard')
  • category
    : 页面分类(例如:'Docs'、'Marketing')
  • properties
    : 包含页面特定属性的对象(url、title、referrer)
注意事项:
  • 必须提供
    userId
    anonymousId
    中的至少一个
  • name
    category
    为可选,但推荐使用以确保分析准确性
  • 标准属性包括
    url
    title
    referrer
    path
    search
  • 页面调用通常为自动触发;手动调用适用于服务器端页面跟踪

6. Alias Users and Manage Sources

6. 用户别名设置与源管理

When to use: User wants to merge anonymous and identified users, or manage source configuration
Tool sequence:
  1. SEGMENT_ALIAS
    - Link two user identities together [Optional]
  2. SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE
    - View source schema settings [Optional]
  3. SEGMENT_UPDATE_SOURCE
    - Update source configuration [Optional]
Key parameters:
  • For ALIAS:
    • userId
      : New user identifier (the identified ID)
    • previousId
      : Old user identifier (the anonymous ID)
  • For source operations:
    • sourceId
      : Source identifier
Pitfalls:
  • ALIAS is a one-way operation; cannot be undone
  • previousId
    is the anonymous/old ID,
    userId
    is the new/identified ID
  • Not all destinations support alias calls; check destination documentation
  • ALIAS should be called once when a user first identifies (e.g., signs up)
  • Source updates may affect data collection; review changes carefully
适用场景:用户需要合并匿名与已识别用户,或管理源配置
工具流程:
  1. SEGMENT_ALIAS
    - 关联两个用户身份 [可选]
  2. SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE
    - 查看源架构设置 [可选]
  3. SEGMENT_UPDATE_SOURCE
    - 更新源配置 [可选]
关键参数:
  • 对于ALIAS:
    • userId
      : 新用户标识符(已识别的ID)
    • previousId
      : 旧用户标识符(匿名ID)
  • 对于源操作:
    • sourceId
      : 源标识符
注意事项:
  • ALIAS为单向操作;无法撤销
  • previousId
    为匿名/旧ID,
    userId
    为新/已识别ID
  • 并非所有目标系统都支持alias调用;请查看目标系统文档
  • 应在用户首次识别(例如注册)时调用一次ALIAS
  • 源配置更新可能影响数据收集;请仔细审核更改内容

Common Patterns

常见模式

User Lifecycle

用户生命周期

Standard Segment user lifecycle:
1. Anonymous user visits -> PAGE call with anonymousId
2. User interacts -> TRACK call with anonymousId
3. User signs up -> ALIAS (anonymousId -> userId), then IDENTIFY with traits
4. User takes action -> TRACK call with userId
5. User joins org -> GROUP call linking userId to groupId
标准Segment用户生命周期:
1. Anonymous user visits -> PAGE call with anonymousId
2. User interacts -> TRACK call with anonymousId
3. User signs up -> ALIAS (anonymousId -> userId), then IDENTIFY with traits
4. User takes action -> TRACK call with userId
5. User joins org -> GROUP call linking userId to groupId

Batch Optimization

批量优化

For bulk data ingestion:
1. Collect events in memory (array of message objects)
2. Each message includes type, userId/anonymousId, and type-specific fields
3. Call SEGMENT_BATCH with the collected messages
4. Check response for any individual message errors
对于批量数据导入:
1. Collect events in memory (array of message objects)
2. Each message includes type, userId/anonymousId, and type-specific fields
3. Call SEGMENT_BATCH with the collected messages
4. Check response for any individual message errors

Naming Conventions

命名规范

Segment recommends consistent event naming:
  • Events: Use "Object Action" format (e.g., 'Order Completed', 'Article Viewed')
  • Properties: Use snake_case (e.g., 'order_total', 'product_name')
  • Traits: Use snake_case (e.g., 'first_name', 'plan_type')
Segment推荐统一的命名规范:
  • Events: 使用"Object Action"格式(例如:'Order Completed'、'Article Viewed')
  • Properties: 使用蛇形命名法(snake_case,例如:'order_total'、'product_name')
  • Traits: 使用蛇形命名法(例如:'first_name'、'plan_type')

Known Pitfalls

已知注意事项

Identity Resolution:
  • Always include
    userId
    or
    anonymousId
    on every call
  • Use ALIAS only once per user identity merge
  • Identify before tracking to ensure proper user association
Data Quality:
  • Event names should be consistent across all sources
  • Properties should follow a defined schema for downstream compatibility
  • Avoid sending sensitive PII unless destinations are configured for it
Rate Limits:
  • Use BATCH for bulk operations to stay within rate limits
  • Individual calls are rate-limited per source
  • Batch calls are more efficient and less likely to be throttled
Response Parsing:
  • Successful responses indicate acceptance, not delivery to destinations
  • Response data may be nested under
    data
    key
  • Check for error fields in batch responses for individual message failures
Timestamps:
  • Must be ISO 8601 format with timezone (e.g., '2024-01-15T10:30:00Z')
  • Omitting timestamp uses server receive time
  • Historical data imports should include explicit timestamps
身份解析:
  • 每个调用必须包含
    userId
    anonymousId
  • 每个用户身份合并仅调用一次ALIAS
  • 先调用IDENTIFY再调用TRACK,以确保正确的用户关联
数据质量:
  • 事件名称应在所有源中保持一致
  • 属性应遵循定义的架构,以确保下游兼容性
  • 除非目标系统已配置支持,否则请勿发送敏感的个人可识别信息(PII)
速率限制:
  • 使用BATCH进行批量操作,以避免超出速率限制
  • 单个调用的速率限制基于每个源
  • 批量调用效率更高,更不容易被限流
响应解析:
  • 响应成功仅表示事件已被接收,不代表已送达目标系统
  • 响应数据可能嵌套在
    data
    键下
  • 检查批量响应中的错误字段,以查看单个消息是否失败
时间戳:
  • 必须为带时区的ISO 8601格式(例如:'2024-01-15T10:30:00Z')
  • 若省略时间戳,则使用服务器接收时间
  • 历史数据导入应包含明确的时间戳

Quick Reference

快速参考

TaskTool SlugKey Params
Track eventSEGMENT_TRACKuserId, event, properties
Identify userSEGMENT_IDENTIFYuserId, traits
Batch callsSEGMENT_BATCHbatch (array of messages)
Group userSEGMENT_GROUPuserId, groupId, traits
Page viewSEGMENT_PAGEuserId, name, properties
Alias identitySEGMENT_ALIASuserId, previousId
Source schemaSEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCEsourceId
Update sourceSEGMENT_UPDATE_SOURCEsourceId
WarehousesSEGMENT_LIST_CONNECTED_WAREHOUSES_FROM_SOURCEsourceId
任务工具标识关键参数
跟踪事件SEGMENT_TRACKuserId, event, properties
识别用户SEGMENT_IDENTIFYuserId, traits
批量调用SEGMENT_BATCHbatch (数组形式的消息对象)
用户群组关联SEGMENT_GROUPuserId, groupId, traits
页面浏览跟踪SEGMENT_PAGEuserId, name, properties
身份别名设置SEGMENT_ALIASuserId, previousId
查看源架构设置SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCEsourceId
更新源配置SEGMENT_UPDATE_SOURCEsourceId
查看关联数据仓库SEGMENT_LIST_CONNECTED_WAREHOUSES_FROM_SOURCEsourceId