line-flex-message

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LINE Flex Message & Reliability Skill

LINE Flex Message 与可靠性技能

This skill extends Claude's ability to design high-quality, brand-consistent LINE Flex Messages and implement reliable messaging workflows.
本技能扩展了Claude的能力,使其能够设计高质量、符合品牌一致性的LINE Flex消息,并实现可靠的消息传递工作流。

Core Capabilities

核心能力

  1. Advanced Flex Layouts: Precise control over nested boxes, dynamic widths, and complex UI patterns (e.g., flight tickets, product lists).
  2. Video Integration: Guidelines and templates for embedding video components in the hero block.
  3. Reliable Communication: Implementing
    X-Line-Retry-Key
    and exponential backoff strategies to handle 429/5xx errors.
  1. 高级Flex布局:精确控制嵌套盒子、动态宽度和复杂UI模式(如机票、产品列表)。
  2. 视频集成:在Hero区块中嵌入视频组件的指南和模板。
  3. 可靠通信:实现
    X-Line-Retry-Key
    和指数退避策略以处理429/5xx错误。

Workflow Patterns

工作流模式

1. Designing a Complex Flex Message

1. 设计复杂的Flex消息

  1. Identify Layout: Determine if it's a single Bubble or a Carousel.
  2. Component Mapping: Map UI elements to Flex blocks (Header, Hero, Body, Footer).
  3. Refine Nesting: Use
    scripts/flex_builder.py
    or reference
    references/flex-elements.md
    to create multi-layer box nesting.
  4. Add Actionability: Ensure all buttons and images have correct
    action
    definitions.
  1. 确定布局:判断是单Bubble还是Carousel类型。
  2. 组件映射:将UI元素对应到Flex区块(Header、Hero、Body、Footer)。
  3. 优化嵌套结构:使用
    scripts/flex_builder.py
    或参考
    references/flex-elements.md
    创建多层盒子嵌套。
  4. 添加交互性:确保所有按钮和图片都有正确的
    action
    定义。

2. Implementing API Retries

2. 实现API重试

  1. Generate Key: Use
    scripts/flex_builder.py
    to generate a unique
    X-Line-Retry-Key
    .
  2. Header Injection: Always include the retry key in the first request for supported APIs (Push, Multicast, etc.).
  3. Error Handling: Follow the decision matrix in
    references/retry-policy.md
    :
    • 429/5xx/Timeout: Retry with exponential backoff.
    • 409: Log as "already accepted" and proceed.
    • 2xx: Success.
  1. 生成密钥:使用
    scripts/flex_builder.py
    生成唯一的
    X-Line-Retry-Key
  2. 注入请求头:在支持的API(Push、Multicast等)的首次请求中始终包含重试密钥。
  3. 错误处理:遵循
    references/retry-policy.md
    中的决策矩阵:
    • 429/5xx/超时:使用指数退避策略重试。
    • 409:记录为“已接受”并继续执行。
    • 2xx:请求成功。

Resources

资源

  • Flex Elements & Layout Guide: Detailed component specifications.
  • Flex Video Guide: Requirements and examples for video embedding.
  • Retry & Reliability Policy: Strategic guide for headers and error handling.
  • Flex Builder Script: Python utility for generating complex Flex JSON and retry headers.
  • Flex元素与布局指南:详细的组件规格说明。
  • Flex视频集成指南:视频嵌入的要求和示例。
  • 重试与可靠性策略:请求头与错误处理的策略指南。
  • Flex构建脚本:用于生成复杂Flex JSON和重试请求头的Python工具。

Layout Patterns Examples

布局模式示例

  • Product List: Use nested horizontal boxes for image + text rows.
  • Video Hero: Mega/Giga sized bubbles with
    type: video
    in hero block.
  • Carousel: Side-scrolling bubbles for browsing multiple items.
  • 产品列表:使用嵌套水平盒子实现图片+文本行布局。
  • 视频Hero区块:Mega/Giga尺寸的气泡,在Hero区块中设置
    type: video
  • 轮播(Carousel):横向滚动的气泡,用于浏览多个项目。

Quality Standards

质量标准

  • Consistency: Use
    spacing
    and
    margin
    consistently across bubbles.
  • Responsiveness: Use
    wrap: true
    for text and test layouts with different font sizes.
  • Stability: Never send high-frequency messages without a retry strategy.
  • 一致性:在所有气泡中统一使用
    spacing
    margin
    属性。
  • 响应式:为文本设置
    wrap: true
    ,并在不同字体大小下测试布局。
  • 稳定性:在未配置重试策略的情况下,切勿发送高频消息。