Use from software
The widget is one way to use incdai. Your own apps can use the same assistant: a mobile app, a point-of-sale screen, a kiosk, a chatbot on another channel, or a voice assistant in the terminal.
Everything below works with incdai Public (https://api.incdai.incpritech.com) and with an authorized compatible node. You only need the site id and node origin; public endpoints don't need an owner key.
JavaScript
The public client works in modern browsers and standards-based JavaScript runtimes.
import { Incdai } from "https://api.incdai.incpritech.com/sdk.js";
const incdai = new Incdai({ api: "https://api.incdai.incpritech.com", site: "your-site" });
// stream the answer as it's written
for await (const piece of incdai.stream("Mnafungua saa ngapi?")) {
process.stdout.write(piece);
}
// or wait for the whole answer
const reply = await incdai.answer("Do you offer school transport?");
console.log(reply.text, reply.answered, reply.language);
The client remembers the conversation, so follow-up questions work (incdai.reset() starts over). In Node.js you can also copy sdk.js into your project and import it from a file.
| Method | What it does |
|---|---|
stream(question) | Async iterator of answer text, piece by piece. |
answer(question) | The whole answer: {text, answered, language, sources, handoff}. |
events(question) | Every event, including the final done event. |
transcribe(audio) | Speech to text for a recording (a Blob or bytes): {text, language}. |
speak(text) | Text to speech: audio bytes in an English voice. |
lead({name, contact, message}) | Leave contact details for the business. |
live(options) | A real-time voice conversation. See Live voice. |
config() | The assistant's public settings. |
Any other language
Every SDK method is a plain HTTP request, so PHP, Java, Go, Kotlin, Swift or Dart apps can call the HTTP API directly. For live voice, open a WebSocket and follow the live protocol.
curl -N https://api.incdai.incpritech.com/v1/sites/your-site/ask \
-H "Content-Type: application/json" \
-d '{"question": "Do you offer school transport?"}'
Good to know
- Questions from your software count toward the same daily plan limit as questions from your website.
- If your profile lists allowed websites, browsers on other websites are refused. Apps and servers that don't send an
Originheader are not affected. - Don't put your site key (
vk_…) in an app. The public endpoints don't need it; keep it on your server for the owner endpoints.