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

# APIリファレンス

> 以下のドキュメントを通じてAPIを独自に呼び出し、対話機能を実装して、独自の対話ウィンドウに埋め込むことができます。独自のアダプテーションが必要なユーザーに適しています。secretとclientは、MarsMind Intelligenceに申請して取得する必要があります。

## リクエストパラメータ

### 本体構造

<ParamField body="client" type="string" required>
  ビジネス識別子、MarsMind Intelligenceに確認してください
</ParamField>

<ParamField body="signature" type="string" required>
  署名、以下のアルゴリズムを参照
</ParamField>

<ParamField body="timestamp" type="integer" required>
  タイムスタンプ（Unix秒単位）
</ParamField>

<ParamField body="message_info" type="object" required>
  メッセージ詳細、以下のフィールド定義を参照
</ParamField>

### `message_info` フィールド

<ParamField body="msg_id" type="string">
  一意のメッセージID、assist\_dialogシナリオでは必須
</ParamField>

<ParamField body="group_id" type="string">
  グループチャットID、from\_user\_idとgroup\_idが共に空の場合はエラー400
</ParamField>

<ParamField body="group_name" type="string">
  グループチャット名
</ParamField>

<ParamField body="from_user_id" type="string" required>
  送信者ID
</ParamField>

<ParamField body="from_user_nickname" type="string">
  送信者ニックネーム
</ParamField>

<ParamField body="to_user_id" type="string">
  受信者ID
</ParamField>

<ParamField body="to_user_nickname" type="string">
  受信者ニックネーム
</ParamField>

<ParamField body="at_list" type="string[]">
  @ユーザーIDのリスト（auto\_dialogのみサポート）
</ParamField>

<ParamField body="content" type="string">
  メッセージテキスト内容、contentとfiles\_infoの少なくとも1つは必須
</ParamField>

<ParamField body="message_type" type="integer" required>
  1 = 通常メッセージ、2 = 引用メッセージ
</ParamField>

<ParamField body="event_type" type="string" required>
  auto\_dialog | assist\_dialog | website\_dialog | cmd\_dialog
</ParamField>

<ParamField body="from_user_type" type="integer">
  1=ロボットバインディングアカウント 2=顧客 3=カスタマーサービス 4=ロボットメッセージ。auto\_dialogでは必須
</ParamField>

<ParamField body="create_timestamp" type="integer" required>
  メッセージ作成時間（Unixタイムスタンプ）
</ParamField>

<ParamField body="files_info" type="File[]">
  添付ファイルリスト、下表参照。contentとfiles\_infoの少なくとも1つは必須
</ParamField>

<ParamField body="quote" type="object">
  引用メッセージオブジェクト、msg\_id、message\_typeを含む必要があります。message\_type=2の場合は必須
</ParamField>

#### `files_info` 構造

<ParamField body="content" type="string" required>
  ファイルアドレスまたはbase64データ
</ParamField>

<ParamField body="file_type" type="string" required>
  "image"/"document"/"voice"
</ParamField>

***

## 対話シナリオの説明

### auto\_dialog（自動対話）

* `event_type = auto_dialog`
* `send_url` を提供し、MarsMind Intelligenceがメッセージロジックを自動制御します
* テキスト、画像、ファイルをサポート（リクエストごとに一意のタイプ）

**from\_user\_type 記入の提案：**

* バインディング対象：インテリジェントアシスタント自身のメッセージを除き、すべて1を記入
* 非バインディング対象：外部顧客は2、同社の人員は3を記入

***

### assist\_dialog（補助対話）

* `event_type = assist_dialog`
* メッセージ処理結果をリアルタイムで返します
* パラメータがauto\_dialogメッセージと一致する場合、コンテキストが再利用されます

***

### website\_dialog（ウェブサイト対話）

* `event_type = website_dialog`
* メッセージはすぐに結果を返し、コンテキストに統合されます。send\_urlはサポートされていません

***

### cmd\_dialog（コマンド制御）

* `event_type = cmd_dialog`
* contentは具体的なコマンドで、現在以下をサポートしています：
  * `stop_auto_reply`：自動返信を停止（auto\_dialogシナリオでのみ有効）

***

## 呼び出し例

### auto\_dialog

```bash theme={null}
curl -X POST http://127.0.0.1:7002/custom-im/chat-messages \
-H "Content-Type: application/json" \
-d '{
  "client": "test",
  "signature": "d97b383a532466b6c6c451e76a2ab57b",
  "timestamp": 1748584621,
  "message_info": {
    "content": "",
    "message_type": 1,
    "group_id": "98765@chatroom",
    "event_type": "auto_dialog",
    "from_user_id": "aa123",
    "from_user_type": 2,
    "msg_id": "9005",
    "create_timestamp": 1748584621,
    "files_info": [
      { "content": "https://example.com/img.png", "file_type": "image" }
    ]
  }
}'
```
