What Is the ask() API for Websites?

The ask() API is a method (OkidokiWidget.ask()) that lets developers query the Okidoki.chat AI directly from client-side JavaScript. Instead of opening the chat widget, you can programmatically ask a question and receive a structured JSON response based on your knowledge base. It is ideal for building custom AI-powered features — like smart search, product recommendations, or dynamic FAQs — without setting up your own LLM pipeline.

How the ask() API Works

Call OkidokiWidget.ask() with a natural language question and an optional JSON Schema for the response format. The AI queries your knowledge base using RAG and returns a typed response that your frontend code can use directly.

Structured Output with JSON Schema

Pass a JSON Schema to define the exact shape of the AI's response. For example, request an array of product recommendations with name, price, and reason fields. The AI conforms its output to your schema, making integration seamless.

Use Cases for the ask() API

Build smart site search that understands intent, create "AI picks for you" recommendation widgets, generate dynamic FAQ sections, or power comparison tools — all using your existing Okidoki.chat knowledge base.

Developer Experience

The SDK includes full TypeScript types. Responses are returned as promises, making it easy to use with async/await. Rate limits and error handling are documented in the developer portal.

Frequently Asked Questions

Is the ask() API available on all plans?

The ask() API is available on all paid plans. Rate limits vary by plan tier.

Does it use the same knowledge base as the chat widget?

Yes. The ask() API queries the same documents, website content, and PDFs that power your chat widget.

Can I use it server-side?

The ask() API is designed for client-side use via the widget SDK. For server-side access, use the REST API.

Is there a latency impact on the page?

Requests are asynchronous and do not block page rendering. Typical response time is 1–3 seconds.

Ready to try Okidoki.chat?

Turn your website visitors into scheduled meetings. Free 7-day trial, setup in 5 minutes.

Start Free Trial

Related Questions