Sending a question (realtime)
POST /api/v1/ai/query
The query endpoint always gives you a chat-data object that has the original question and the response it generated. Normally, you would use this object to show the response in your view. It’s important to use the chatDataJson property when you ask any more questions to make sure the conversation history is kept correctly.
Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters ”Your API key from account settings.
Request Body required
Section titled “Request Body required ”object
The question you want to send to the AI.
Your account ID. See: https://unless.com/en/dashboard/account/settings
Your API key. See: https://unless.com/en/dashboard/account/settings
The website ID you trained the AI on.
An unique identifier for your visitor.
An unique identifier for the current session.
In case you have multiple topics, you can give each a different name.
Optional segment to search in.
You can provide an audienceId to be used for content lookup. Use comma-separated id’s to supply multiple.
Send an additional metadata object that we’ll show in the dashboard.
You can set this value to ‘html’ if you want the messages formatted as html instead of markdown.
The AI will validate if the question asked is in the same language as the current conversation language. If that doesn’t match, the AI will send back a command to switch the conversation language. You can turn off this language check using this property, which means the AI will always respond in the conversation language.
Our chat-data wrapper for managing history. See the response at the right for an example. To maintain a proper history, which is important for follow-up questions and logging, you should supply this with every query (except the first query).
Responses
Section titled “ Responses ”Successful response containing updated chat data.
Conversation state object returned by query endpoints.
object
Array of conversation turns.
object
object
Arbitrary metadata associated with the conversation.
object
Example
{ "history": [ { "type": "message", "timestamp": 1687956110772, "uuid": "57c1968c-1b49-48d5-a484-ed299e609b8a", "hidden": false, "sender": "user", "message": "What does Unless do?", "metadata": [], "languageCode": "en", "showMetadata": false, "canGetFeedback": false, "feedback": "" }, { "type": "message", "timestamp": 1687956112605, "uuid": "5aa331df-1e6d-4ee2-b6aa-93176e521469", "hidden": false, "sender": "bot", "canGetFeedback": true, "message": "Unless is a tool that allows companies to create highly personalized and compelling landing pages to highlight their benefits compared to competitors. It also offers AI training to become an expert in a company's product and provides conversational UI components.", "metadata": [ { "title": "Rapid experimentation", "isPublic": true, "isUsedForAnswer": true, "source": "https://unless.com/en/blog/customer-cases/rapid-experimentation-at-prenatal/", "documentId": "4c0cbe48-bd8b-403e-bbad-3d16a9c679c9", "stableId": "c37310599c08a2a2d5295fbd98c42a34", "trainingDataId": "1e61e2e6-8b3f-4b90-8703-a40aa6d7783f" } ], "showMetadata": false, "feedback": "" } ], "metadata": {}, "toolsetName": null, "personalizationId": "", "sessionId": "23d1b8d1-64f5-4dd2-8122-73e56d0c78ff", "conversationName": null, "conversationId": "e796d388-ddb3-4ab6-9891-06f2e4dd16cb"}