Delta Key құжаттамасы

Жылдам бастау

Идеядан алғашқы жұмыс істейтін ЖИ-қызметкерге дейінгі негізгі жол.

Басты қағидатАлдымен рөлді, нәтижені және шектеулерді анықтаңыз. Тек содан кейін ғана білімді, арналарды және құралдарды қосыңыз.

Негізгі тұжырымдамалар

  1. ЖИ-қызметкер - түсінікті міндеті мен жауапкершілігі бар жеке рөл.
  2. Регламент - қарым-қатынас стилі, міндетті нақтылаулар, тыйымдар және эскалация туралы нұсқаулық.
  3. Білім базасы - жауаптар құрылатын құжаттар, беттер, каталогтар және құрылымдалған деректер.
  4. Құралдар - CRM, helpdesk, дүкен, есепке алу жүйесінде немесе API арқылы рұқсат етілген әрекеттер.
  5. Арналар - клиенттермен және қызметкерлермен байланыс нүктелері.

1. ЖИ-қызметкер құрыңыз

Рөлді таңдап, күтілетін нәтижені сипаттаңыз. Жақсы тұжырым үш сұраққа жауап береді: қызметкер кіммен жұмыс істейді, қандай міндетті шешеді және оның өкілеттіктері қай жерде аяқталады.

Рөл мысалы
Рөл: интернет-дүкеннің ЖИ-кеңесшісі
Мақсаты: клиентке тауар таңдауға және тапсырыс жасауға көмектесу
Рұқсат етілген: каталогты оқу, қалдықтарды тексеру, лид жасау
Рұқсат етілмеген: ережесіз жеңілдік уәде ету, бағаны өзгерту
Адамға береді: даулы қайтарулар және стандартты емес шарттар

2. Білім базасын қосыңыз

Рөлге шын мәнінде қажет құжаттар мен дереккөздерді қосыңыз. Анықтамалық ақпаратты, ережелерді және жедел деректерді бөліп қойыңыз.

  • Нұсқаулықтар мен регламенттер
  • Тауарлар мен қызметтердің сипаттамасы
  • Төлем, жеткізу және қайтару шарттары
  • Жиі қойылатын сұрақтар және расталған жауаптар
  • Өзекті деректер жүйелеріне сілтемелер

3. Арнаны қосыңыз

Пилот үшін бір арна жеткілікті. Сапа тексерілгеннен кейін сол қызметкер Telegram-да, WhatsApp-та, сайтта, email арқылы немесе басқа интерфейсте қолжетімді болуы мүмкін.

4. Құралдарды қосыңыз

Құрал жауапты әрекетке айналдырады. Мысалы, қызметкер лид жасай, тапсырыс мәртебесін ала, клиентті жазып қоя, тикет рәсімдей немесе міндет қоя алады.

Дерекқорлар

Жүйелер жүктелуде…

Customer login: Delta Key protocol

Connect Customer login under Integrations. Enter a public HTTPS endpoint and configure the same signing secret in your system and Delta Key. Select AI employees and choose Check and enable. Login becomes available in their widgets after verification. Customers use your company credentials; they do not need a Delta Key account.

Endpoint and security

Implement a POST endpoint accepting UTF-8 JSON. HTTPS, port 443, a public domain and a valid TLS certificate are required. Query strings, fragments, credentials in the URL and redirects are rejected. Verify the signature before checking a password and allow only your expected owner.guid. Use a 32–128 character printable ASCII secret without spaces, literally, without hex decoding. A recommended secret is 32 random bytes encoded as 64 hex characters.

Headers: Content-Type: application/json, X-AI2-Source: ai2, X-AI2-Timestamp (UTC Unix seconds), X-AI2-Signature (hex HMAC-SHA256). Existing header names are retained for compatibility. Sign this exact string:

POST\n<path>\n<timestamp>\n<raw_body>

Use the original request bytes before JSON decoding. path is the external URL path without the domain; an empty path means /. Compare signatures in constant time. Reject time differences over 300 seconds, mismatched body ts and timestamp header, and reused request_id values. Atomically retain replay keys for 600 seconds in storage shared by all processes. Never log passwords, secrets, full request bodies or personal response data. Apply brute-force limits in your own system and limit request bodies to 8 KiB.

Check and enable

Delta Key sends a signed request to your endpoint:

{"protocol":"deltakey-client-auth/1","type":"ping","owner":{"kind":"business","guid":"YOUR_COMPANY_GUID"},"request_id":"32-hex-characters","ts":1795000000,"challenge":"64-random-hex-characters"}

Respond with HTTP 200:

{"ok":true,"protocol":"deltakey-client-auth/1","capabilities":["login"],"challenge":"the-same-challenge","proof":"hex-HMAC-SHA256"}

Calculate proof using the same secret over the following string. It proves that your endpoint has the shared secret; HTTP 200 alone is insufficient.

DELTAKEY-CLIENT-AUTH-CHECK\n<owner.guid>\n<challenge>\n<request_id>

Verify credentials

{"protocol":"deltakey-client-auth/1","type":"login","form_id":42,"owner":{"kind":"business","guid":"YOUR_COMPANY_GUID"},"request_id":"32-hex-characters","ts":1795000000,"fields":{"login":"C-1001","password":"customer-password"}}

Verify credentials in your system. Passwords are sent unchanged, including spaces, and may contain up to 1024 bytes; login is limited to 200 characters. Return HTTP 200 on success:

{"ok":true,"client":{"external_id":"C-1001","name":"Anna Ivanova","email":"[email protected]","phone":"+48123456789"}}

external_id is the required permanent ID within your company, up to 100 characters. name is required, up to 150 characters. email and phone are optional: include only contacts your system confirms belong to this customer. Do not return passwords, password hashes, secrets or platform administrator roles.

Use the same HTTP 200 response for an incorrect password, unknown customer or denied login: {"ok":false,"error":"invalid_credentials"}. This avoids account enumeration. HTTP 401/403 means an integration signature/access failure; HTTP 429 with Retry-After means a temporary rate limit; 5xx means your system is unavailable. Invalid JSON or missing required customer fields is a protocol error. Customers receive a readable message, not the upstream technical response.

Connection timeout: 5 seconds; total timeout: 12 seconds; maximum response: 64 KiB. Login is never retried automatically. Delta Key reserves rate budgets before sending: 5 attempts per customer per company in 15 minutes, 20 per IP per hour, 100 per company per minute. Successful attempts also count. Secret rotation does not reset these budgets.

Sessions, data and permissions

After success, Delta Key stores the customer ID and name and opens a revocable 12-hour session. Passwords are never stored, logged or sent to the AI. The connection secret is stored encrypted. Disabling the connection or changing the endpoint, secret or selected employees revokes its sessions. Endpoint/secret changes require verification again.

The AI employee receives a verified customer card. Login grants no additional write permissions and does not connect other systems automatically. Other integrations follow company permissions. Customer tools verify order ownership against a server-confirmed contact; identifiers typed in chat do not replace verified identity.

Live data can use the existing customer service protocol with a separate lookup endpoint and service key. Requests include type: lookup, question, refs, owner, request_id, ts and client.external_id. Example: {"type":"lookup","question":"order_status","refs":["7781"],"client":{"external_id":"C-1001"}}; response: {"ok":true,"answer":{"text":"Order ready","facts":{"status":"ready"}}}. Use the same signature format with the separate service key. Lookup timeouts: 3 seconds for connection, 5 seconds total. Verify customer ownership of the requested object in your system. Requests and approvals use the existing process journal.

Handler examples

The PHP and Node.js functions below accept your own customer lookup and password verification functions. Implement claim/claimRequest with shared Redis SET key 1 NX EX 600. Perform equivalent password-check work for unknown customers. Pass the external path, enforce POST at the route, and return status and body as JSON. Your web server must enforce body limits and prevent sensitive logging.

PHP

<?php
declare(strict_types=1);
/** Пример обработчика. $claim атомарно занимает ключ на 600 с в общем хранилище (Redis SET NX EX).
 * $find и $verify работают с вашей учётной системой. Пароль и тело запроса не журналируются.
 * Результат: ['status'=>HTTP-код,'body'=>JSON-объект]. HTTPS и ограничения тела задаются веб-сервером. */
return static function(string $raw,array $headers,string $company,string $secret,callable $find,callable $verify,callable $claim,string $path):array {
    $reply=static fn(int $status,array $body)=>['status'=>$status,'body'=>$body];
    $deny=static fn()=> $reply(200,['ok'=>false,'error'=>'invalid_credentials']);
    if(strlen($secret)<32 || strlen($raw)>8192)return $reply(400,['ok'=>false]);
    $h=array_change_key_case($headers,CASE_LOWER);$ts=$h['x-ai2-timestamp']??'';$sig=$h['x-ai2-signature']??'';
    if(($h['x-ai2-source']??'')!=='ai2'||!preg_match('/^[0-9]{10}$/D',$ts)||abs(time()-(int)$ts)>300
        || !hash_equals(hash_hmac('sha256',"POST\n".$path."\n".$ts."\n".$raw,$secret),$sig))return $reply(401,['ok'=>false]);
    $b=json_decode($raw,true);
    if(!is_array($b)||($b['protocol']??null)!=='deltakey-client-auth/1'||($b['ts']??null)!==(int)$ts
        ||($b['owner']['kind']??null)!=='business'||($b['owner']['guid']??null)!==$company
        ||!is_string($b['request_id']??null)||!preg_match('/^[a-f0-9]{32}$/D',$b['request_id']))return $reply(400,['ok'=>false]);
    if(!$claim(hash('sha256',$company.'|'.$b['request_id']),600))return $reply(409,['ok'=>false]);
    if(($b['type']??null)==='ping'){
        $challenge=$b['challenge']??null;if(!is_string($challenge)||!preg_match('/^[a-f0-9]{64}$/D',$challenge))return $reply(400,['ok'=>false]);
        return $reply(200,['ok'=>true,'protocol'=>'deltakey-client-auth/1','capabilities'=>['login'],'challenge'=>$challenge,
            'proof'=>hash_hmac('sha256',"DELTAKEY-CLIENT-AUTH-CHECK\n".$company."\n".$challenge."\n".$b['request_id'],$secret)]);
    }
    $login=$b['fields']['login']??null;$password=$b['fields']['password']??null;
    if(($b['type']??null)!=='login'||!is_string($login)||!is_string($password)||$login===''||$password===''||strlen($password)>1024)return $reply(400,['ok'=>false]);
    $c=$find($login);
    // $verify проверяет пароль в вашей системе; для отсутствующего клиента выполняет эквивалентную по времени проверку.
    if(!$verify($c,$password)||!$c||!empty($c['blocked']))return $deny();
    return $reply(200,['ok'=>true,'client'=>array_intersect_key($c,array_flip(['external_id','name','email','phone']))]);
};

Node.js

import { createHmac, createHash, timingSafeEqual } from 'node:crypto'

// Пример обработчика: findCustomer/verifyPassword работают с вашей системой.
// claimRequest(key, ttl) - общий атомарный Redis SET NX EX; тело и пароль не журналируйте.
export async function customerLogin({ raw, headers, path, company, secret, findCustomer, verifyPassword, claimRequest }) {
  const reply = (status, body) => ({ status, body })
  const fail = status => reply(status, { ok: false })
  if (typeof secret !== 'string' || secret.length < 32 || Buffer.byteLength(raw) > 8192) return fail(400)
  const ts = String(headers['x-ai2-timestamp'] || ''), sig = String(headers['x-ai2-signature'] || '')
  const expected = createHmac('sha256', secret).update(`POST\n${path}\n${ts}\n${raw}`).digest('hex')
  if (headers['x-ai2-source'] !== 'ai2' || !/^\d{10}$/.test(ts) || Math.abs(Date.now() / 1000 - Number(ts)) > 300
      || !/^[a-f0-9]{64}$/.test(sig) || !timingSafeEqual(Buffer.from(expected), Buffer.from(sig))) return fail(401)
  let b
  try { b = JSON.parse(raw) } catch { return fail(400) }
  if (b?.protocol !== 'deltakey-client-auth/1' || b.ts !== Number(ts) || b.owner?.kind !== 'business' || b.owner.guid !== company
      || typeof b.request_id !== 'string' || !/^[a-f0-9]{32}$/.test(b.request_id)) return fail(400)
  const key = createHash('sha256').update(`${company}|${b.request_id}`).digest('hex')
  if (!await claimRequest(key, 600)) return fail(409)
  if (b.type === 'ping') {
    if (typeof b.challenge !== 'string' || !/^[a-f0-9]{64}$/.test(b.challenge)) return fail(400)
    const proof = createHmac('sha256', secret).update(`DELTAKEY-CLIENT-AUTH-CHECK\n${company}\n${b.challenge}\n${b.request_id}`).digest('hex')
    return reply(200, { ok: true, protocol: 'deltakey-client-auth/1', capabilities: ['login'], challenge: b.challenge, proof })
  }
  const { login, password } = b.fields || {}
  if (b.type !== 'login' || typeof login !== 'string' || !login || typeof password !== 'string' || !password || Buffer.byteLength(password) > 1024) return fail(400)
  const customer = await findCustomer(login)
  // При отсутствии клиента verifyPassword также выполняет эквивалентную по времени проверку.
  if (!await verifyPassword(customer, password) || !customer || customer.blocked) return reply(200, { ok: false, error: 'invalid_credentials' })
  const client = Object.fromEntries(['external_id', 'name', 'email', 'phone'].filter(k => typeof customer[k] === 'string').map(k => [k, customer[k]]))
  return reply(200, { ok: true, client })
}

5. Тестілеу жүргізіңіз

Әдеттегі, күрделі және тыйым салынған сценарийлерді тексеріңіз. Дәлдікті, толықтықты, регламентке сәйкестікті, әрекеттердің дұрыстығын және адамға беру сапасын бағалаңыз.

REST API

API дайын адаптері жоқ жүйелермен интеграциялау үшін, сондай-ақ жеке интерфейстер мен бизнес-логика үшін пайдаланылады.

curl
BODY='{"rows":[{
  "external_id": "C-1001",
  "event_at": "2026-10-28T09:00:00Z",
  "kind": "order",
  "ref": "7781",
  "key": "статус заказа",
  "value": "собран",
  "external_ref": "evt-88112"
}]}'
SIGNATURE=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "<ключ приёма>" | sed 's/^.* //')

curl -X POST "https://api.deltakey.kz/public/cs/business/<GUID компании>/events" \
  -H "Content-Type: application/json" \
  -H "X-AI2-Signature: $SIGNATURE" \
  --data-binary "$BODY"

API хаттамасы

Webhooks

Webhooks сыртқы жүйеге оқиғалар туралы хабарлайды: лид жасалды, диалог операторға берілді, тапсырыс расталды немесе әрекет қатемен аяқталды. Форматтар, қолтаңба және қайталаулар мына бөлімде сипатталған: API хаттамасындағы webhooks.

Қауіпсіздік

Әрбір құрал үшін жеке құқықтар беріледі. Құпия кілттер модель нұсқаулықтарына қосылмайды, ал әрекеттер бақылау және тергеп-тексеру үшін журналға жазылады.

МаңыздыӨнеркәсіптік іске қосу алдында қолжетімділік саясатын, деректерді сақтауды, ақпаратты жою тәртібін және сценарийлер сапасына жауапты тұлғаларды бекіту қажет.

Ұсынымдар

Шектеулі сценарийден бастаңыз, сапаны нақты өтініштерде тексеріңіз және ЖИ өкілеттіктерін тек нәтиже расталғаннан кейін ғана кеңейтіңіз.

Сұрақтар мен жауаптар

Тарифтер, интеграциялар, орналастыру және пилоттық іске қосу туралы сұрақтарға жауаптар тарифтер бетінде жинақталған және консультацияда нақтыланады.

Архитектура бойынша көмек қажет пе?

Сіздің жүйелеріңізді талдап, арналар, деректер, құралдар және ЖИ рөлдерінің схемасын дайындаймыз.

Бізбен байланысу