⚠️ This documentation pertains to a preview endpoint. This feature is not yet ready for API consumption and may change.
For inquiries or feedback, please contact us at Glean.

Detect and answer questions

post/ask

Classify a query as information seeking or not. If so, generate an AI answer and/or provide relevant documents. Useful for integrating into existing chat interfaces.

SecurityBearerAuth
Request
header Parameters
X-Glean-Auth-Type
string

Auth type being used to access the endpoint (should be non-empty only for global tokens).

X-Scio-Actas
string <email>

Email address of a user on whose behalf the request is intended to be made (should be non-empty only for global tokens).

Request Body schema: application/json

Ask request

required
object (SearchRequest)
object (AskExperimentalMetadata)
backend
string

Which backend to use to fulfill the requests.

Enum: Description
SEARCH

Issue a search request and return a search result.

CHAT

Issue a chat request and return a generated response.

chatApplicationId
string

The ID of the application this request originates from, used to determine the configuration of underlying chat processes when invoking the CHAT backend. This should correspond to the ID set during admin setup. If not specified, the default chat experience will be used.

detectOnly
boolean

Whether to apply only question detection and not answering.

Array of objects or objects or objects (DocumentSpec)

A list of Glean Document IDs to be excluded when retrieving documents. Note that, currently, it only supports exclusion of one Glean Documnet ID based spec. If multiple specifications are provided only the first Glean Document ID based spec is excluded and the remaining specs are ignored.

operators
string

Search operators to append to the query

Responses
200

OK

Response Schema: application/json
isQuestion
required
boolean

Whether or not the query was a question.

question
string

The part of the query which was used as a question for search

object (SearchResponse)
400

Invalid request

401

Not Authorized

403

Forbidden

422

Invalid Query

429

Too Many Requests

Request samples
application/json
{
  • "detectOnly": true,
  • "AskExperimentalMetadata": {
    • "QueryHasMentions": true,
    • "QueryIsLengthAppropriate": true,
    • "QueryIsAnswerable": true
    },
  • "searchRequest": {
    • "trackingToken": "trackingToken",
    • "query": "vacation policy",
    • "pageSize": 10,
    • "requestOptions": {
      • "facetFilters": [
        • {
          • "fieldName": "type",
          • "values": [
            • {
              • "value": "article",
              • "relationType": "EQUALS"
              },
            • {
              • "value": "document",
              • "relationType": "EQUALS"
              }
            ]
          },
        • {
          • "fieldName": "department",
          • "values": [
            • {
              • "value": "engineering",
              • "relationType": "EQUALS"
              }
            ]
          }
        ]
      }
    },
  • "excludedDocumentSpecs": [
    • {
      • "url": "string"
      }
    ],
  • "operators": "string",
  • "backend": "SEARCH",
  • "chatApplicationId": "string"
}
Response samples
application/json
{
  • "isQuestion": true,
  • "question": "string",
  • "searchResponse": {
    • "trackingToken": "trackingToken",
    • "suggestedSpellCorrectedQuery": "suggestedSpellCorrectedQuery",
    • "hasMoreResults": true,
    • "errorInfo": {
      • "errorMessages": [
        • {
          • "source": "gmail",
          • "errorMessage": "invalid token"
          },
        • {
          • "source": "slack",
          • "errorMessage": "expired token"
          }
        ]
      },
    • "requestID": "5e345ae500ff0befa2b9d1a3ba0001737e7363696f312d323535323137000171756572792d656e64706f696e743a323032303031333074313830343032000100",
    • "results": [
      • {
        • "snippets": [
          • {
            • "snippet": "snippet",
            • "mimeType": "mimeType"
            }
          ],
        • "metadata": {
          • "container": "container",
          • "createTime": "2000-01-23T04:56:07.000Z",
          • "datasource": "datasource",
          • "author": {
            • "name": "name"
            },
          • "documentId": "documentId",
          • "updateTime": "2000-01-23T04:56:07.000Z",
          • "mimeType": "mimeType",
          • "objectType": "objectType"
          },
        • "title": "title",
        },
      • {
        • "snippets": [
          • {
            • "snippet": "snippet",
            • "mimeType": "mimeType"
            }
          ],
        • "metadata": {
          • "container": "container",
          • "createTime": "2000-01-23T04:56:07.000Z",
          • "datasource": "datasource",
          • "author": {
            • "name": "name"
            },
          • "documentId": "documentId",
          • "updateTime": "2000-01-23T04:56:07.000Z",
          • "mimeType": "mimeType",
          • "objectType": "objectType"
          },
        • "title": "title",
        }
      ],
    • "facetResults": [
      • {
        • "buckets": [
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            },
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            }
          ],
        • "sourceName": "sourceName",
        • "operatorName": "operatorName",
        • "objectType": "objectType"
        },
      • {
        • "buckets": [
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            },
          • {
            • "percentage": 5,
            • "count": 1,
            • "value": {
              • "stringValue": "stringValue",
              • "integerValue": 5
              }
            }
          ],
        • "sourceName": "sourceName",
        • "operatorName": "operatorName",
        • "objectType": "objectType"
        }
      ],
    • "rewrittenQuery": "rewrittenQuery",
    • "rewrittenFacetFilters": [
      • {
        • "fieldName": "fieldName",
        • "values": [
          • "fieldValues",
          • "fieldValues"
          ]
        },
      • {
        • "fieldName": "fieldName",
        • "values": [
          • "fieldValues",
          • "fieldValues"
          ]
        }
      ]
    }
}