The Ask module allows your users to ask questions in natural language and receive AI-generated answers based on your content. This guide walks you through the four steps to get it running.
1
Obtain Your API Key
Log in to the Miso Dashboard, select your target environment (e.g., Production), and navigate to the Overview section to copy your Publishable API Key.
There is one publishable key and one secret key per environment. The publishable key is used in client-side code; the secret key is used for server-side API calls.
Step 1 β Set your request headersIn Postman, go to the Headers tab and add your Secret API Key:
Header
Value
X-API-KEY
Your Secret API Key
Content-Type
application/json
Step 2 β Add your request bodySwitch to the Body tab, select raw β JSON, and paste your corpus data:
{ "data": [ { "product_id": "art_001", "title": "Your Article Title Here", "url": "https://yoursite.com/your-article", "cover_image": "https://yoursite.com/cover.png", "description": "A brief description of the article content.", "html": "" // Full article HTML content, JSON-escaped }, { "product_id": "art_002", "title": "Another Article Title", "url": "https://yoursite.com/another-article", "cover_image": "https://yoursite.com/cover2.png", "description": "Another article description.", "html": "" // Full article HTML content, JSON-escaped } ]}
Step 3 β Send and verifyClick Send. A 200 OK response confirms the corpus has been uploaded successfully.You can verify the upload under Miso Dashboard β Data Sets β Catalog.
3
Install the Miso SDK
Add the Miso JavaScript SDK to your webpage using either method:
Configure the workflow by adding the following script:
<script> const misocmd = window.misocmd || (window.misocmd = []); misocmd.push(async () => { // setup client const MisoClient = window.MisoClient; const client = new MisoClient('YOUR_PUBLISHABLE_API_KEY'); const rootWorkflow = client.ui.ask; // wait for styles to be loaded await client.ui.ready; // render DOM and get element references // default templates are available since v1.9.1 const defaults = MisoClient.ui.defaults.ask; const templates = defaults.templates; const rootElement = document.querySelector('#miso-ask-combo'); rootElement.innerHTML = templates.root(); // setup workflows // uncomment the following lines if your SDK version is older than v1.12.5 // defaults.wireFollowUps(client, rootElement.querySelector(`.miso-ask-combo__follow-ups`)); // defaults.wireRelatedResources(client, rootElement.querySelector(`.miso-ask-combo__related-resources`)); // start query if specified in URL parameters rootWorkflow.autoQuery(); });</script>
Replace YOUR_PUBLISHABLE_API_KEY with the key obtained in Step 1. To test, open the page in a browser and add ?q=your+question to the URL.
Once configured, the Miso Ask module provides a professional, interactive UI out of the box.To verify your setup is working:
Open client_sdk_test_ask.html in a browser.
Append ?q=media to the URL β you should see an AI-generated answer based on your uploaded corpus, along with follow-up suggestions and related resources.
API keys can be passed via the api_key query parameter or the X-API-KEY request header. There is one publishable key and one secret key per environment β use the publishable key in client-side code and the secret key for server-side API calls.