How to ask a question to a Smart Assistant

This example demonstrates how use the graphQL API to ask question to a smart assistants, or perform a semantic search Note that Smart Assistants need to be included in your plan and enabled on the platform for this to work.

First, find the ID of the smart assistant that you want to use

graphql
query listSA {
me {
smartAssistants(first: 3) {
edges {
node {
id
label
}
}
}
}
}
response
{
"data": {
"me": {
"smartAssistants": {
"edges": [
{
"node": {
"id": "U21hcnRBc3Npc3RhbnQ6MQ==",
"label": "Security Advisor"
}
},
{
"node": {
"id": "U21hcnRBc3Npc3RhbnQ6Mg==",
"label": "Product Documentation"
}
},
{
"node": {
"id": "U21hcnRBc3Npc3RhbnQ6Mw==",
"label": "Customer Success Agent "
}
}
]
}
}
}
}

You then use it's ID to ask a question or perform a semantic search:

graphql
query AnswerExample {
node(id: "U21hcnRBc3Npc3RhbnQ6Mg==") {
... on SmartAssistant {
answer(query: "What is a tag in Elium ? ") {
text
sources {
... on AnswerAssetSource {
asset {
slug
__typename
... on FileAsset {
filename
}
}
}
... on Story {
slug
version {
title
}
}
}
}
}
}
}

Expected result:

response
{
"data": {
"node": {
"answer": {
"text": "In Elium, a tag is a keyword or label that is used to categorize and organize information. Tags are grouped into families, called categories, and they help to classify and filter content within the knowledge management system. Tags make it easier to search for and access specific information, and they provide a way to create dynamic gateways to information within Elium.",
"sources": [
{
"asset": {
"slug": "138994",
"__typename": "FileAsset",
"filename": "product documentation export.pdf"
}
}
]
}
}
}
}

Was this page helpful?