Skip to main content

Single-Shot Questions Tutorial

This tutorial demonstrates how to submit single-shot questions to Knowledge Discovery agents and retrieve answers.

Prerequisites

  • Valid access token (see Authentication)
  • At least one configured agent with data sources
  • Discovery User role or higher

Tutorial Overview

In this tutorial, you'll learn to:

  1. Submit a question to an agent
  2. Retrieve answers with source references
  3. Provide feedback on answers
  4. Retrieve question history

Part 1: Submit a Simple Question

Basic Question Submission

Let's start by submitting a simple question to an agent.

POST {{baseUrl}}/agent/agents/{{agentId}}/questions
Authorization: Bearer {{accessToken}}
Hxp-Environment: {{environmentKey}}
Hxp-App: {{appKey}}
Content-Type: application/json

{
"question": "What is the company's vacation policy for new employees?",
"dynamicFilter": null
}

Understanding Question Parameters

ParameterRequiredDescription
questionYesThe natural language question text
dynamicFilterNoRuntime filter expression to apply to the search
Asynchronous Processing

The POST /agents/{agentId}/questions endpoint returns 202 Accepted immediately. The question is processed asynchronously. Poll the GET endpoint to retrieve the answer once ready.

Part 2: Retrieve the Answer

After submitting a question, retrieve the answer using the question ID.

GET {{baseUrl}}/qna/questions/{{questionId}}/answer
Authorization: Bearer {{accessToken}}

Answer Response Structure

{
"answer": "New employees are eligible for 15 days of paid vacation per year...",
"agentId": "hr-agent-id",
"agentVersion": 1,
"responseCompleteness": "Complete",
"objectReferences": [
{
"objectId": "doc-123",
"references": [
{
"referenceId": "chunk-456",
"rankScore": 0.95,
"rank": 1
}
]
}
],
"question": "What is the company's vacation policy for new employees?",
"feedback": null,
"staticFilter": null,
"dynamicFilter": null
}

Response Completeness Values

ValueMeaning
SubmittedQuestion has been submitted and is being processed
CompleteAnswer has been generated and is ready
ErrorAn error occurred during processing

Part 3: Provide Feedback

Users can provide feedback on answers to help improve the system.

POST {{baseUrl}}/qna/questions/{{questionId}}/answer/feedback
Authorization: Bearer {{accessToken}}
Hxp-Environment: {{environmentKey}}
Hxp-App: {{appKey}}
Content-Type: application/json

{
"feedback": "Good"
}

Feedback Values

Supported feedback types:

  • "Good" - Answer was helpful and accurate
  • "Bad" - Answer was not helpful or contained errors
  • "Retry" - Request to regenerate the answer

Part 4: Retrieve Question History

Retrieve the history of questions asked to a specific agent.

GET {{baseUrl}}/qna/agents/{{agentId}}/questions/history?pageNumber=1&pageSize=50
Authorization: Bearer {{accessToken}}
Hxp-Environment: {{environmentKey}}
Hxp-App: {{appKey}}

Query Parameters

ParameterRequiredDefaultDescription
pageNumberNo1Page number for pagination
pageSizeNo100Number of items per page (max: 100)
maxContentLengthNonullMaximum length of question/answer content (10-1000)

Response Structure

{
"data": [
{
"id": "c9d6f822-e88c-48a7-bfb9-1f91e7214b40",
"question": "What is the company's vacation policy for new employees?",
"answer": "New employees are eligible for 15 days of paid vacation per year...",
"dateCreated": "2025-11-12T10:30:00Z",
"dateAnswered": "2025-11-12T10:30:15Z",
"agentVersion": 1,
"responseCompleteness": "Complete",
"feedback": "Good",
"staticFilter": null,
"dynamicFilter": null
},
{
"id": "a1b2c3d4-e5f6-4789-a012-3456789abcde",
"question": "What are the office hours?",
"answer": "Office hours are Monday to Friday, 9 AM to 5 PM.",
"dateCreated": "2025-11-12T09:15:00Z",
"dateAnswered": "2025-11-12T09:15:10Z",
"agentVersion": 1,
"responseCompleteness": "Complete",
"feedback": null,
"staticFilter": null,
"dynamicFilter": null
}
],
"pagination": {
"pageSize": 50,
"pageNumber": 1,
"totalItems": 125,
"totalPages": 3
}
}

Understanding the Response

FieldTypeDescription
dataarrayArray of question history items
data[].idUUIDQuestion identifier
data[].questionstringThe question text
data[].answerstring (nullable)The answer text (null if error or still processing)
data[].dateCreateddatetimeWhen the question was submitted
data[].dateAnswereddatetime (nullable)When the answer was generated
data[].agentVersionintegerVersion of the agent used
data[].responseCompletenessenumStatus: Submitted, Complete, Error
data[].feedbackenum (nullable)User feedback: Good, Bad, Retry
data[].staticFilterobject (nullable)Static filters applied
data[].dynamicFilterobject (nullable)Dynamic filters applied
pagination.pageSizeintegerItems per page
pagination.pageNumberintegerCurrent page number
pagination.totalItemsintegerTotal number of questions
pagination.totalPagesintegerTotal number of pages

Summary

In this tutorial, you learned how to:

✅ Submit questions to agents
✅ Retrieve answers with source references
✅ Provide feedback on answer quality
✅ Retrieve question history for an agent