> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langbot.app/llms.txt
> Use this file to discover all available pages before exploring further.

# 通过机器人发送消息

> 通过指定的机器人向目标发送消息。仅支持 API Key 认证。



## OpenAPI

````yaml /openapi/service-api-zh.json post /api/v1/platform/bots/{bot_uuid}/send_message
openapi: 3.0.3
info:
  title: LangBot Service API
  description: |
    LangBot 外部服务 API 文档。这些接口支持 API 密钥认证，供外部系统以编程方式访问 LangBot 资源。

    **认证方式：**
    - 用户令牌（通过 `Authorization: Bearer <token>`）
    - API 密钥（通过 `X-API-Key: <key>` 或 `Authorization: Bearer <key>`）

    本文档中的所有接口都同时支持这两种认证方式（除特别说明外）。
  version: 4.9.5
  contact:
    name: LangBot
    url: https://langbot.app
  license:
    name: AGPL-3.0
    url: https://github.com/langbot-app/LangBot/blob/master/LICENSE
servers:
  - url: http://localhost:5300
    description: 本地开发服务器
security:
  - ApiKeyAuth: []
  - BearerAuth: []
tags:
  - name: 模型供应商
    description: 模型供应商管理。供应商定义了 API 地址和密钥，模型通过 provider_uuid 关联到供应商。
  - name: 大语言模型
    description: 大语言模型 (LLM) 管理。每个模型关联到一个供应商。
  - name: 向量模型
    description: 向量模型 (Embedding) 管理。每个模型关联到一个供应商。
  - name: 机器人
    description: 机器人实例管理及消息发送
  - name: 流水线
    description: 流水线（Pipeline）配置管理
  - name: 知识库
    description: 知识库管理操作
  - name: 知识引擎
    description: 知识引擎（插件提供）的查询
  - name: 解析器
    description: 文件解析器（插件提供）的查询
  - name: 文件
    description: 文件上传操作
  - name: 插件
    description: 插件安装、配置和管理
  - name: 系统
    description: 系统信息（无需认证）
paths:
  /api/v1/platform/bots/{bot_uuid}/send_message:
    post:
      tags:
        - 机器人
      summary: 通过机器人发送消息
      description: 通过指定的机器人向目标发送消息。仅支持 API Key 认证。
      parameters:
        - name: bot_uuid
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - target_type
                - target_id
                - message_chain
              properties:
                target_type:
                  type: string
                  enum:
                    - person
                    - group
                  description: 目标类型
                target_id:
                  type: string
                  description: 目标 ID（用户 ID 或群组 ID）
                message_chain:
                  type: array
                  description: 消息链
                  items:
                    type: object
                    properties:
                      type:
                        type: string
                        enum:
                          - Plain
                          - Image
                          - At
                          - Voice
                        description: 消息元素类型
                      text:
                        type: string
                        description: 文本内容（Plain 类型）
                      url:
                        type: string
                        description: 图片 URL（Image 类型）
                      target:
                        type: string
                        description: '@ 的目标 ID（At 类型）'
                  example:
                    - type: Plain
                      text: Hello, World!
      responses:
        '200':
          description: 发送成功
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: integer
                    example: 0
                  data:
                    type: object
                    properties:
                      sent:
                        type: boolean
                        example: true
        '400':
          description: 参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        code:
          type: integer
          example: -1
        msg:
          type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
    BearerAuth:
      type: http
      scheme: bearer

````