Docs menuAsk the AI for an answer
API documentationBahasa Indonesia

POST/api/v2/ai/agents/{id}/replies

Ask the AI for an answer

An AI Agent's answer to one customer message in your app, with that agent's Behaviour, knowledge, and Q&A.

Klik Flow sends nothing to the customer: your app shows reply. Send only the new message; Klik Flow remembers the last 16 turns of the session for 24 hours after its last message, and answers one message at a time per session. An answer takes a few seconds, so give the request a 60-second timeout. Live keys use AI credits at the price "AI Agent answers for apps (API)" (Jawaban AI Agent untuk aplikasi (API)); test keys answer within the free AI test quota (Uji AI) and use no credits. Call it from your app's server only, with an Idempotency-Key. See the Ask an AI Agent guide.

Send an Idempotency-Key header (for example a new UUID per request). A repeat with the same key within 24 hours gets the first answer again, so nothing is sent twice.

After outcome: "handoff", show reply, then direct the customer to your team: the next message in that session gets session_handoff (409) until the session is closed or 24 hours pass.

Key
kf_live_ / kf_test_… in the Authorization: Bearer header. Created in Settings › API & Webhook › Create key (Pengaturan › API & Webhook › Buat kunci).
Key scope
ai:reply
Plan feature
WhatsApp sending API, AI Agent (automatic replies)

Path parameters

  • idintegerrequired

    Agent id from List AI Agents.

Body (JSON)

  • messagestringrequired

    The customer's message, at most 4,000 characters.

  • session_idstringrequired

    A session id from your app, one per app user: 1–128 letters, digits, or . _ : @ -. Messages with the same session_id are answered with their history in mind.

  • customerobject

    Optional: { "ref", "name", "phone" }. name is used to greet the customer. phone (8–15 digits with the country code) opens that customer's order status when the key also has the contacts:read scope and the agent's order status switch in AI Agent › Integration (AI Agent › Integrasi) is on. ref (the customer's id in your app) is accepted but not used to answer.

  • formatstring: plain | whatsapp | markdown

    Shape of the reply text: plain without formatting (default), whatsapp with *bold* and _italics_, or markdown.

Possible errors

Try it

Try it with a test key
Path parameters
/api/v2/ai/agents/{id}/replies

Send WhatsApp from your system with the Klik Flow API.

Mulai dengan paket Free. Ajak tim setelah ruang kerja siap.