Chat REST API: send messages to the chatbot

On this page

The chatbot's public routes live under /wp-json/wpbot-chatbot/v1/. They answer with the same engine as the chat window: Simple Text Responses, Dialogflow, site search, the knowledge base, AI and the fallback, with your answer settings, Business Context and spending limits. Use them to build your own chat interface or to let a kiosk, app or another site ask your chatbot.

1. Get a visitor token

curl -X POST https://example.com/wp-json/wpbot-chatbot/v1/token
{ "token": "v1.1795000000.3f2a…", "expires": 1795086400 }

The token is valid for 24 hours and is not tied to a page, so it also works for pages served from a full-page cache. Fetch it when the chat opens, not when the page is built. Send it with every other request in the X-WPBot-Token header (or as a token field).

2. Send a message

curl -X POST https://example.com/wp-json/wpbot-chatbot/v1/message \
  -H "Content-Type: application/json" \
  -H "X-WPBot-Token: v1.1795000000.3f2a…" \
  -d '{"text":"Do you ship to Canada?","session_id":"kiosk-0042","page_url":"https://example.com/shipping/","language":"en_US"}'
FieldRequiredWhat it is
textyesThe visitor's message
session_idrecommendedYour id for the conversation (6–128 characters: letters, digits, _ - . :). Messages with the same id share history and form one session in ChatBot → Sessions
namenoThe visitor's name, if known
languagenoThe locale, for example en_US
page_url, page_titlenoThe page the visitor is on; used when Use the current page is on
historynoEarlier messages as `[ { "role": "user" \"assistant", "content": "…" } ]`
extranostrid (a chosen Simple Text Response), intent, ai_action
streamnotrue for server-sent events

The answer:

{
  "source": "ai",
  "text": "Yes, we ship to Canada. Delivery takes 5–7 business days.",
  "html": "",
  "data": { },
  "meta": { "provider": "openai", "model": "…" }
}

source tells you which step answered: str (Simple Text Responses), search (site search, with result cards in html and data), ai, dialogflow or fallback. text can contain Markdown; html is already safe HTML.

3. Stream the answer

With "stream": true the route answers with server-sent events: a series of {"type":"text","text":"…"} pieces while the AI writes, then one {"type":"done","reply":{…}} with the full reply in the format above. Providers without streaming send the answer as one piece.

4. Save visitor details and leads

RouteFieldsAnswer
POST /session/{session_id}name, email, phone, source_url{ "status": "success" }
POST /leadname, email and/or phone, url, languageThe same message the chat shows after a sign-up

A lead saved here fires qcld_wpbot_chat/lead_captured, so it reaches AI Marketing and your own hooks like any chat lead. The routes /feedback and /report serve the chat window's like, dislike and report buttons.

Limits and errors

StatusCodeMeaning
403qcld_wpbot_chat_tokenThe token is missing or expired: fetch a new one
400qcld_wpbot_chat_emptyNo text was sent
429qcld_wpbot_chat_rate_limitedToo many requests from this IP address: wait and try again

Every route is rate limited per IP address, and AI answers follow the chatbot's AI limits (by default 60 AI answers a day for visitors who are not logged in) and your Limit chatbot AI answers per user role. Requests sent from one server all share that server's IP address, so for a server-side integration raise the limits with the qcld_wpbot_chat/rate_limit filter, or pass the real visitor's address through qcld_wpbot_chat/visitor_ip when your proxy is trusted. When an AI spending limit is reached, the chatbot still answers from saved answers, FAQ and site search.

Tip

Visitors' messages and answers are stored like chat window conversations, so they appear in ChatBot → Sessions (while chat sessions are saved) and unanswered questions in ChatBot → Train. Tell your users in your privacy policy.

Availability

In every edition, including WPBot Free.

Got more questions?

Contact our ChatBot Support Heroes. They’ll provide you with all the information you need.

Contact us

Customer support is very responsive and professional. The script is awesome and with many features, including A.I. from Dialogflow. High quality.

Newpolaris

If have a 7 Stars won’t hesitate to rate that chatbot as a 7stars+++ Very helpful prompt team support Cannot find enough words express my happiness for purchasing that CHATBot Good Luck for you and your items

Ahsmartsolutions

© 2002- 2026 QuantumCloud

Black Friday! Use coupon code monster for a discount during checkout!

DISCOUNT!

X
Let's chat if you need any help finding the right product or need support.
FAQSend Us Email