コンテンツにスキップ

チャンネル

Show:

チャンネルAPIを使用すると、SchiftをKakaoTalkなどのメッセージングプラットフォームに接続できます。ユーザーメッセージをウェブフックで受信し、バケットに対してRAGクエリを実行し、ユーザーに通知を送信できます。

Note: チャンネル設定を変更または一覧表示するすべてのエンドポイントは、Authorization: Bearer $SCHIFT_API_KEYによるAPIキー認証が必要です。Kakaoのウェブフックエンドポイントはbot_id認証を使用します。

Kakao i Open Builderスキルコールバックを介してKakaoTalkからユーザーメッセージを受信します。このエンドポイントはRAGを実行し、ユーザーのメッセージを埋め込み、チャンネル設定にリンクされたバケットを検索し、結果をKakaoTalkのsimpleText形式で返します。

このエンドポイントは、リクエストボディに含まれるbot_idで認証されます。bot_idは登録されたチャンネル設定と一致する必要があります。secretが設定されている場合、リクエストには有効なx-kakao-timestampx-kakao-signatureヘッダーも含める必要があります。

FieldTypeRequiredDescription
bot_idstringYesチャンネル設定に登録されたボット識別子。
user_idstringYesKakaoTalkユーザーID。
utterancestringYesユーザーのメッセージテキスト。

KakaoTalkのsimpleTextレスポンスを返します:

{
"version": "2.0",
"template": {
"outputs": [
{
"simpleText": {
"text": "Search results..."
}
}
]
}
}
StatusDescription
400無効なJSONボディ。
403無効または欠落したbot_id、不明なチャンネル設定、または無効なウェブフック署名。
429レート制限超過(bot_idごとに60秒間に30リクエスト)。
Terminal window
curl -X POST ${API_BASE_URL:-https://api.example.com}/v1/channels/kakao/webhook \
-H "Content-Type: application/json" \
-d '{
"bot_id": "bot-abc123",
"user_id": "user-xyz789",
"utterance": "법인세 계산 방법"
}'

Response:

{
"version": "2.0",
"template": {
"outputs": [
{
"simpleText": {
"text": "1. (score: 0.92)\n법인세는 기업의 순이익에 대해 부과되는 세금입니다.\n\n2. (score: 0.88)\n기본세율은 정상기업 기준 22%입니다."
}
}
]
}
}

ユーザーにアリムトーク(KakaoTalk通知)を送信します。APIキー認証が必要です。

FieldTypeRequiredDescription
channel_config_idstringYesPOST /v1/channels/configsからのチャンネル設定ID。
phonestringYes受取人の電話番号。
template_codestringYesKakaoビジネスダッシュボードからのKakaoテンプレートコード。
template_argsobjectNoテンプレート変数としてのキーと値の文字列。
user_idstringNoKakaoTalkユーザーID(直接メッセージングのためのphoneの代替)。
messagestringNoテンプレートを使用しない場合の自由形式のメッセージテキスト。
FieldTypeDescription
statusstring成功時は"sent"
resultobjectKakao APIのレスポンス詳細、message_idsent_atを含む。
StatusDescription
400template_codeまたはphoneが欠落しています。
404チャンネル設定が見つかりません。
Terminal window
curl -X POST ${API_BASE_URL:-https://api.example.com}/v1/channels/kakao/send \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCHIFT_API_KEY" \
-d '{
"channel_config_id": "config-abc123",
"phone": "01012345678",
"template_code": "template_001",
"template_args": {
"product_name": "Schift API",
"discount_percent": "20%"
}
}'

Response:

{
"status": "sent",
"result": {
"message_id": "msg-abc123",
"sent_at": 1609459200000
}
}

プロバイダー固有の資格情報と設定を保存する新しいチャンネル設定を登録します。

FieldTypeRequiredDescription
namestringYes設定の表示名。
providerstringYesプロバイダータイプ、例: "kakao", "slack", "discord"
configobjectYesプロバイダー固有の設定オブジェクト。

Kakaoの場合、configオブジェクトには以下を含める必要があります:

FieldTypeRequiredDescription
rest_api_keystringYesKakao REST APIキー。
channel_idstringYesKakaoチャンネルID。
admin_keystringNoKakao管理キー。
collectionstringYesRAGクエリに使用されるバケット名。
bot_idstringYesウェブフック認証に使用されるボットID。
FieldTypeDescription
idstring一意の設定ID。
namestring設定名。
providerstringプロバイダータイプ。
StatusDescription
400無効または欠落した必須フィールド。
401欠落または無効なAPIキー。
Terminal window
curl -X POST ${API_BASE_URL:-https://api.example.com}/v1/channels/configs \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SCHIFT_API_KEY" \
-d '{
"name": "Legal RAG Bot",
"provider": "kakao",
"config": {
"rest_api_key": "xxxxxxxxxxxxxxxx",
"channel_id": "channel-123",
"bot_id": "bot-abc123",
"collection": "legal-docs"
}
}'

Response:

{
"id": "config-abc123",
"name": "Legal RAG Bot",
"provider": "kakao"
}

組織のすべてのチャンネル設定を取得します。APIシークレットはレスポンスでマスクされます。

設定オブジェクトの配列を返します:

[
{
"id": "config-abc123",
"name": "Legal RAG Bot",
"provider": "kakao",
"config": {
"rest_api_key": "xxxxxx...xxxx",
"channel_id": "channel-123",
"collection": "legal-docs"
}
}
]
StatusDescription
401欠落または無効なAPIキー。
Terminal window
curl ${API_BASE_URL:-https://api.example.com}/v1/channels/configs \
-H "Authorization: Bearer $SCHIFT_API_KEY"

チャンネル設定を永久に削除します。

ParameterTypeDescription
config_idstring一意の設定ID。
FieldTypeDescription
deletedboolean削除が成功した場合はtrue
StatusDescription
401欠落または無効なAPIキー。
404設定が見つかりません。
Terminal window
curl -X DELETE ${API_BASE_URL:-https://api.example.com}/v1/channels/configs/config-abc123 \
-H "Authorization: Bearer $SCHIFT_API_KEY"

Response:

{
"deleted": true
}

このドキュメントのすべてのエンドポイントはv1チャンネルAPIの一部です。現在、v2バージョンはありません。