NeyBee AI Chat Widget API
Third-Party Integration Documentation v1.0.0
Tanggal : 29 NOV 2026 - 01:28 AM
Source: ChatGPT
1. Introduction
NeyBee AI Chat Widget API memungkinkan aplikasi pihak ketiga menghubungkan layanan dan member mereka ke AI Chat Engine milik NeyBee melalui KUPI API.
Contoh integrasi:
-
UhuyNET —
www.uhuy.net -
WANotif
-
Platform atau aplikasi lain yang memiliki API Client terdaftar di NeyBee.
Dengan integrasi ini, aplikasi pihak ketiga dapat menyediakan layanan AI Chat kepada member mereka tanpa harus mengelola AI Engine sendiri.
API Provider: NeyBee
API Base URL: https://api.neybee.com
Service: AI Chat Widget
Endpoint: POST /api/ai-chat-widget/v1/chat
Authentication: HMAC SHA-256
2. Integration Architecture
Arsitektur integrasi menggunakan komunikasi server-to-server.
┌──────────────────────────────┐
│ Member UhuyNET │
│ │
│ Mengirim pesan AI │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ www.uhuy.net │
│ │
│ 1. Validasi sesi member │
│ 2. Ambil external_member_id │
│ 3. Buat HMAC Signature │
└──────────────┬───────────────┘
│ HTTPS
▼
┌──────────────────────────────┐
│ api.neybee.com │
│ │
│ AI Chat Widget │
│ │
│ 1. Autentikasi API Client │
│ 2. Validasi Member Identity │
│ 3. Validasi Subscription │
│ 4. Validasi Usage Quota │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ KUPI API │
│ │
│ AI Chat Engine │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ Response NeyBee │
│ │
│ Answer + Conversation ID │
└──────────────┬───────────────┘
│
▼
┌──────────────────────────────┐
│ www.uhuy.net │
│ │
│ Menampilkan jawaban AI │
└──────────────────────────────┘
3. Requirements
Sebelum melakukan integrasi, aplikasi pihak ketiga harus memiliki:
-
API Client yang telah terdaftar di NeyBee.
-
Public Key dan Secret Key API Client.
-
Scope
ai_chat_widget. -
Integration Identity yang aktif untuk member yang akan menggunakan layanan.
-
Subscription Plan dan fitur AI Chat Widget yang aktif sesuai ketentuan NeyBee.
API Client dan Secret Key dikelola melalui sistem NeyBee. Jangan membuat Secret Key sendiri untuk menggantikan kredensial yang diberikan NeyBee.
4. API Endpoint
Chat Request
POST https://api.neybee.com/api/ai-chat-widget/v1/chat
Headers:
Content-Type: application/json
Accept: application/json
X-NeyBee-Public-Key: YOUR_PUBLIC_KEY
X-NeyBee-Timestamp: UNIX_TIMESTAMP
X-NeyBee-Nonce: UNIQUE_NONCE
X-NeyBee-Signature: HMAC_SIGNATURE
Semua request harus menggunakan HTTPS.
5. Authentication: HMAC SHA-256
Setiap request harus ditandatangani menggunakan Secret Key API Client.
5.1 Generate Request Body
Contoh payload:
{
"external_member_id": "UHUY-MEMBER-001",
"message": "Halo, apa itu nChat?",
"conversation_id": null
}
5.2 Generate Timestamp
Gunakan Unix timestamp:
$timestamp = time();
5.3 Generate Nonce
Setiap request wajib menggunakan nonce unik.
$nonce = bin2hex(random_bytes(16));
5.4 Generate Body Hash
Hash harus dihitung dari JSON body yang sama persis dengan body yang dikirim.
$bodyHash = hash('sha256', $body);
5.5 Generate Canonical String
Format canonical string:
TIMESTAMP
NONCE
HTTP_METHOD
REQUEST_PATH
BODY_SHA256
Contoh:
$canonical = implode("\n", [
$timestamp,
$nonce,
'POST',
'/api/ai-chat-widget/v1/chat',
$bodyHash,
]);
5.6 Generate Signature
$signature = hash_hmac(
'sha256',
$canonical,
$secretKey
);
Kirim hasil signature melalui header X-NeyBee-Signature.
Penting:
-
Gunakan Secret Key yang diberikan NeyBee.
-
Jangan mengubah urutan canonical string.
-
Jangan menambahkan newline di akhir canonical string.
-
Body yang ditandatangani harus identik dengan body yang dikirim.
-
Timestamp memiliki toleransi waktu default 300 detik.
-
Nonce tidak boleh digunakan ulang.
6. PHP Integration Example
Berikut contoh implementasi server-to-server menggunakan PHP dan cURL.
<?php
function sendNeyBeeAiChat(
string $externalMemberId,
string $message,
?string $conversationId = null
): array {
$baseUrl = 'https://api.neybee.com';
$publicKey = getenv('NEYBEE_PUBLIC_KEY');
$secretKey = getenv('NEYBEE_SECRET_KEY');
$path = '/api/ai-chat-widget/v1/chat';
$url = $baseUrl . $path;
// Build request payload.
$payload = [
'external_member_id' => $externalMemberId,
'message' => $message,
'conversation_id' => $conversationId,
];
// Encode once. Use the same body for hashing and transmission.
$body = json_encode(
$payload,
JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE
);
if ($body === false) {
throw new RuntimeException('Failed to encode request body.');
}
// Authentication data.
$timestamp = (string) time();
$nonce = bin2hex(random_bytes(16));
// Generate body hash.
$bodyHash = hash('sha256', $body);
// Generate canonical string.
$canonical = implode("\n", [
$timestamp,
$nonce,
'POST',
$path,
$bodyHash,
]);
// Generate HMAC SHA-256 signature.
$signature = hash_hmac(
'sha256',
$canonical,
$secretKey
);
// Send request.
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'X-NeyBee-Public-Key: ' . $publicKey,
'X-NeyBee-Timestamp: ' . $timestamp,
'X-NeyBee-Nonce: ' . $nonce,
'X-NeyBee-Signature: ' . $signature,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 75,
]);
$response = curl_exec($ch);
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
curl_close($ch);
if ($response === false) {
throw new RuntimeException(
'NeyBee API connection error: ' . $curlError
);
}
$result = json_decode($response, true);
return [
'http_status' => $httpStatus,
'response' => $result,
];
}
Contoh pemanggilan:
$result = sendNeyBeeAiChat(
'UHUY-MEMBER-001',
'Halo, apa itu nChat?'
);
print_r($result);
Ganti UHUY-MEMBER-001 dengan ID member asli dari aplikasi.
Catatan timeout: KUPI API memiliki request timeout 60 detik dan connection timeout 10 detik. Aplikasi pihak ketiga sebaiknya memberi waktu tunggu lebih panjang dari 60 detik agar tidak memutus request sebelum NeyBee selesai memprosesnya. Contoh di atas menggunakan timeout client 75 detik dan connection timeout 10 detik.
7. Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
external_member_id |
string | Yes | ID unik member pada aplikasi pihak ketiga |
message |
string | Yes | Pesan yang dikirim ke AI |
conversation_id |
string/null | No | ID percakapan sebelumnya |
Batas parameter:
-
external_member_id: maksimal 191 karakter. -
message: maksimal 4.000 karakter. -
conversation_id: maksimal 191 karakter.
Jangan mengirim member_id, client_id, model, atau API Key KUPI. Nilai-nilai tersebut ditentukan dan dikelola oleh NeyBee.
8. Conversation Management
AI Chat Widget mendukung percakapan berkelanjutan melalui conversation_id.
First Message
Kirim conversation_id dengan nilai null atau hilangkan parameter tersebut.
{
"external_member_id": "UHUY-MEMBER-001",
"message": "Halo, saya ingin bertanya.",
"conversation_id": null
}
Simpan conversation_id yang dikembalikan oleh NeyBee.
Next Message
Gunakan kembali ID percakapan tersebut.
{
"external_member_id": "UHUY-MEMBER-001",
"message": "Bisa jelaskan lebih lanjut?",
"conversation_id": "a75cfb24-694c-4f4d-8936-6bf13571f8c2"
}
Simpan ID percakapan per sesi percakapan member di aplikasi pihak ketiga.
Jangan menggunakan satu conversation_id untuk percakapan member yang berbeda.
9. Success Response
Contoh respons:
{
"success": true,
"status": "answered",
"answer": "Halo! nChat adalah platform komunikasi dan layanan bisnis digital dari NeyBee.",
"sources": [],
"conversation_id": "a75cfb24-694c-4f4d-8936-6bf13571f8c2",
"usage_counted": true
}
Field:
| Field | Description |
|---|---|
success |
Status pemrosesan endpoint |
status |
Status hasil AI |
answer |
Jawaban AI |
sources |
Referensi sumber jika tersedia |
conversation_id |
ID percakapan |
usage_counted |
Apakah penggunaan dihitung |
Perlu diperhatikan bahwa HTTP 200 berarti endpoint berhasil memproses request. Status hasil AI tetap harus diperiksa, karena AI dapat mengembalikan no_answer.
10. Error Response
Aplikasi harus menangani HTTP status dan pesan error dari NeyBee.
| HTTP Status | Description |
|---|---|
401 |
API Client authentication failed |
403 |
API Client tidak memiliki izin atau akses |
409 |
Nonce sudah pernah digunakan |
422 |
Request validation failed |
429 |
Rate limit atau kuota penggunaan tercapai |
503 |
KUPI tidak dapat dihubungi atau respons upstream tidak diterima |
Contoh:
{
"success": false,
"message": "API authentication failed"
}
Contoh kegagalan upstream:
{
"success": false,
"message": "Request sudah diteruskan ke KUPI, tetapi respons tidak diterima. Penggunaan tetap dihitung.",
"usage_counted": true
}
Aplikasi pihak ketiga tidak boleh menganggap semua HTTP 200 sebagai jawaban AI yang berhasil. Periksa status dan answer.
11. Member Identity Integration
external_member_id harus menggunakan ID member yang konsisten dan unik di aplikasi pihak ketiga.
Contoh:
| Platform | External Member ID |
|---|---|
| UhuyNET | ID member UhuyNET |
| WANotif | ID member WANotif |
| Platform lain | ID member masing-masing |
Identitas member harus sudah didaftarkan dan diverifikasi melalui mekanisme Member Identity NeyBee.
Jangan mengganti external_member_id setiap kali member mengirim pesan.
NeyBee akan melakukan pencocokan identitas berdasarkan API Client dan integration yang terdaftar. Identitas member dari aplikasi lain tidak otomatis dapat digunakan.
12. Quota and Subscription
Penggunaan AI Chat Widget mengikuti Subscription Plan dan kuota yang ditetapkan pada sisi NeyBee.
Aplikasi pihak ketiga tidak perlu menghitung atau mengurangi kuota NeyBee sendiri.
Ketentuan:
-
Kuota dikelola oleh NeyBee.
-
Perhitungan penggunaan menggunakan periode bulanan.
-
Request yang sudah diteruskan ke KUPI dapat tetap dihitung meskipun respons tidak diterima.
-
Request yang gagal sebelum diteruskan tidak dihitung.
-
Status penggunaan tersedia di sistem pencatatan NeyBee.
Aplikasi pihak ketiga disarankan menyimpan riwayat request dan respons untuk kebutuhan audit dan dukungan pelanggan.
13. Security Best Practices
-
Simpan Public Key dan Secret Key di environment server.
-
Jangan pernah menempatkan Secret Key pada JavaScript, HTML, aplikasi browser, atau source code publik.
-
Semua komunikasi wajib menggunakan HTTPS.
-
Gunakan nonce baru untuk setiap request.
-
Sinkronkan waktu server menggunakan NTP.
-
Jangan mencatat Secret Key atau signature sensitif ke log.
-
Validasi sesi member sebelum mengirim request ke NeyBee.
-
Batasi akses endpoint AI Chat di aplikasi pihak ketiga sesuai sesi member.
-
Simpan
conversation_idberdasarkan member dan sesi percakapan. -
Jangan mengizinkan browser mengirim
external_member_idtanpa validasi server.
14. Integration Checklist
Sebelum production:
-
API Client sudah terdaftar di NeyBee.
-
Public Key dan Secret Key sudah dikonfigurasi.
-
Scope
ai_chat_widgetsudah aktif. -
Integration aplikasi sudah terdaftar.
-
Member Identity sudah terdaftar dan terverifikasi.
-
HMAC signature berhasil divalidasi.
-
Request chat berhasil diterima.
-
conversation_idtersimpan dengan benar. -
Error response ditangani.
-
Timeout client sudah disesuaikan.
-
Secret Key tidak terekspos ke frontend.
15. API Information
| Item | Value |
|---|---|
| Provider | NeyBee |
| API Base URL | https://api.neybee.com |
| Service | AI Chat Widget |
| Version | 1.0.0 |
| Method | POST |
| Endpoint | /api/ai-chat-widget/v1/chat |
| Authentication | HMAC SHA-256 |
| Content Type | application/json |
| AI Backend | KUPI API |
| Request Timeout KUPI | 60 seconds |
| Connection Timeout KUPI | 10 seconds |
NeyBee — One API, Connected AI Services.