Help Center オペレーター認証とディープリンク

オペレーター認証とディープリンク

このガイドでは、API を使用してシステム内のオペレーター用有効な認証トークンを取得する方法と、ディープリンクを使用してチャットパネルへ移動する方法を説明します。

API ベース URL: https://chatapi.smsbat.com/ Swagger: https://chatapi.smsbat.com/index.html

Note: 会社レベルのリクエストでは、Bearer 認証の代わりにトークン(ダッシュボードのプロフィールで確認可能)を使用した X-Authorization-Key ヘッダーを利用できます。


1. 会社トークンの取得

会社トークンを取得するには、会社のログイン認証情報を含む HTTP POST リクエストを /api/company/get-token に送信します。

リクエスト

  • Method: POST
  • URL: https://chatapi.smsbat.com/api/company/get-token
  • Headers: Content-Type: application/json

Body:

{
  "login": "string",
  "password": "string"
}

Response

  • Status Code: 200 (OK)
  • Body: String token ("your_token_string")

Note: Save the received token for subsequent requests.


2. Retrieve Organization List

Send a GET request to /api/company/organization using the company token to list your organizations.

Request

  • Method: GET
  • URL: https://chatapi.smsbat.com/api/company/organization
  • ヘッダー:
    • Authorization: Bearer {token}
    • Accept: text/plain

レスポンス

  • ステータスコード: 200 (OK)
  • 本文:
[
  {
    "id": 6,
    "name": "string"
  }
]

3. 組織別オペレーター取得

/api/operator に organizationId パラメータを使用して GET リクエストを送信します。

リクエスト

  • メソッド: GET
  • URL: https://chatapi.smsbat.com/api/operator?organizationId={id}
  • ヘッダー:
    • Authorization: Bearer {token}
    • Accept: text/plain

レスポンス

  • ステータスコード: 200 (OK)
  • 本文:
[
  {
    "id": 21,
    "name": "string",
    "status": 1,
    "organization": {
      "id": 24,
      "name": "test_costs"
    }
  }
]

4. システムへのオペレーター追加

このエンドポイントにアクセスするには会社トークンを使用し、オペレーターをシステムと同期させます。

リクエスト

  • メソッド: POST
  • URL: https://chatapi.smsbat.com/api/operator/synchronize
  • ヘッダー:
    • Authorization: Bearer {token}
    • Content-Type: application/json

本文:

[
  {
    "organizationId": 24,
    "name": "string"
  }
]

レスポンス

  • ステータスコード: 200 (OK)
  • 本文:
[
  {
    "id": 21,
    "status": 0,
    "name": "string"
  }
]

利用可能なオペレータステータス:

  • アクティブ: 0
  • 非アクティブ: 1
  • 削除済み: 2

5. オペレータトークンの取得

会社トークンで認証し、特定のオペレータ用トークンを取得します。

リクエスト

  • メソッド: POST
  • URL: https://chatapi.smsbat.com/api/operator/get-token
  • ヘッダー:
    • Authorization: Bearer {token}
    • Content-Type: application/json

本文:

{
  "id": 0,
  "expiresAt": "2025-01-20T14:33:34.147Z"
}

expiresAt は必須で、オペレータのセッション期間を決定します(最大 +24 hours)。

レスポンス

  • ステータスコード: 200 (OK)
  • 本文: String token

6. オペレータトークンの検証

オペレーターのトークンの有効性を検証します。

リクエスト

  • メソッド: POST
  • URL: https://chatapi.smsbat.com/api/operator/validate-token
  • ヘッダー:
    • Authorization: Bearer {token}
    • Content-Type: application/json

本文: "operator_token_string"

有効なレスポンス (200 OK):

{
  "isValid": true,
  "operatorId": 0,
  "clientId": 0,
  "expiresAt": "2024-12-28T14:04:15.861Z",
  "error": null
}

7. オペレーター チャット パネルへのディープリンク

外部システム(CRM、ERP、社内ウェブサイト)は、JWTオペレーター・トークンをパラメータとして渡すことで、ディープリンクを利用してチャットパネルを直接開くことができます。 トークンが無効または期限切れの場合、ユーザーはログイン画面にリダイレクトされます。

フォーマット 1: チャット ID による

https://chat.smsbat.com/?chat_raw_id=<chat_id>&token=<jwt_token>

フォーマット 2: 電話番号による

https://chat.smsbat.com/?phone=<phone_number>&token=<jwt_token>

電話番号はE.164国際形式である必要があります。

フォーマット 3: アルファネーム&電話番号による

https://chat.smsbat.com/?from=<bm_id>&phone=<phone_number>&token=<jwt_token>

フォーマット 4: 完全なターゲット詳細

メッセージを取得するソースを正確に指定してください:

https://chat.smsbat.com/?source=<sourceId>&from=<bm_id>&phone=<phone_number>&token=<jwt_token>

チャットソース:

  • 0 - Viber
  • 1 - ViberBot
  • 2 - TelegramBot
  • 3 - WhatsApp
  • 4 - ウィジェット
  • 5 - ロゼトカ
  • 6 - フェイスブック
  • 7 - インスタグラム