Create a new chat session
Start a new chat with the Inkeep Chat API.
Quick Start
The newSessionChatResult
subscription is used to create a new chat and receive a subscription event every time there is a new update to the chat response.
With this subscription, you can stream responses, provide citations, and get run-time analytics of the user chat using websockets.
Try the API Playground for an interactive way to use the newSessionChatResult
API.
Want to try out a REST version of our API? Contact us at support@inkeep.com for the documentation. It's a native proxy on top of our GraphQL API with equivalent functionality.
Reference
newSessionChatResult
Argument | Type | Description |
---|---|---|
input | NewSessionChatResultInput | Required. The input parameters that will be used in the subscription. |
Input Types
NewSessionChatResultInput
Property | Type | Description |
---|---|---|
messageInput | String! | Required. The message input string. |
organizationId | ID! | Required. The ID of the organization. |
integrationId | ID! | Required. The ID of the integration. |
chatMode | ChatMode | The mode of the chat (AUTO , TURBO ). |
outputMode | OutputMode | The output mode of the chat (DEFAULT , SQL , PYTHON , CODE ). |
filters | ChatFiltersInput | Use to scope the considered sources based on context known about the user. |
messageContext | String | Add dynamic context about the user that isn't part of the user's message. This can include in-app or dynamic information that your client can infer about the user that might be helpful for the chat bot. |
userAttributes | JSON | Add key <> value pairs that you'd like to use as filters in our analytics suite. This can include emails, IDs, cohorts, groups, pricing tiers and more. |
tags | [String!] | Tags to add to the chat session metadata. These are useful for batch-testing a set of questions and collecting feedback for an iteration of your chatbot. |
workflowId | String | (Preview). The ID of the workflow. Workflows allow you to define specific scenarios in natural language, that leverage your Inkeep knowledge base. Typical scenarios include migrating from X to Y . Contact us for more information. |
workflowVersion | String | (Preview). The version of the workflow. |
ChatFiltersInput
When we ingest content, we add metadata to the content that is filterable in our search and chat APIs. For example, if you have multiple products or version your product, you can "scope" the chat session if you know the product or product version that the user is interested in.
This might be based on:
- the URL the user is viewing
- a product or version picker in your docs or chat UX
- in-app context you have about the user, like which products or versions they use
By default, we label source documents with a product and product version if it can be inferred from your HTML or URL structure.
If you use our ingestion APIs, you can add your own 'attributes' that are filterable to the source documents and create your own filter queries based on that.
Property | Type | Description |
---|---|---|
product | String | The product name. Used to scope the response to content relevant to a specific product. |
productVersion | String | The product version name. Used to scope the response to content relevant to a specific product version. |
sourceIds | String | The source IDs. |
attributes | JSON | The attributes. |
Filter attributes
Our attributes filtering schema is based on MongoDB's query and projection operators. We currently support $in
, $not
, $and
and $or
operators or conditions.
The attributes
value should be valid within this schema. See an example below
Note that all filters are assumed to follow $and
and by exclusive by default, unless using the $or
operator.
That is, sources not meeting those filters will not be used in the chat response.
Filtering by URLs
You can filter by the URLs by using the recordUrlsByRegex
and recordUrlsByExact
patterns as illustrated below.
Enum Types
ChatMode
This enum is used to set the mode of the chat. It can be either AUTO
or TURBO
.
Values | Description |
---|---|
AUTO | The AUTO mode uses the best models available for better reasoning and instruction following. It supports longer conversations, considers more sources when formulating an answer, and uses additional chain of thought reasoning and other LLM techniques for Q&A. However, it is slower and more expensive. |
TURBO | The TURBO mode is faster and more affordable. It uses standard models (e.g. GPT 3.5-turbo) and supports standard conversation length and input size. It considers standard sources when formulating an answer and uses standard intermediary LLM steps. |
OutputMode
Our API can output conversational outputs (DEFAULT
) or only code-snippets in specific a specific programming language.
Values |
---|
DEFAULT |
SQL |
PYTHON |
TypeScript |
CODE |
Object Types
ChatResult
You don't have to pass in all the historical chat messages for a conversation, we automatically handle this by creating a chat session with a chatSessionId
. For additional messages using the Continue Chat Session, you only need to specify the sessionId and new user message.
Property | Type | Description |
---|---|---|
sessionId | ID! | The ID of the chat session. |
message | BotMessage! | The bot message. |
isEnd | Boolean! | Indicates if the chat session has ended. |
postChatResultSignals | PostChatResultSignals | The post chat result signals. |
BotMessage
Property | Type | Description |
---|---|---|
id | ID! | A unique ID for the message. |
content | String | The content of the message. |
citations | [ChatCitation!]! | The citations in the message. |
codeBlocks | [CodeBlock!] | The code blocks in the message. |
CodeBlock
If using a code-based output mode, this will contain the output as code snippets.
Property | Type | Description |
---|---|---|
language | CodeLanguage! | The language of the code block. |
code | String | The code in the code block. |
ChatCitation
Property | Type | Description |
---|---|---|
citationNumber | Int! | The citation number. |
title | String | The title of the citation. |
url | String! | The URL of the citation. |
rootRecordId | ID | The ID of the root record. |
rootRecordType | RecordType | The type of the root record. |
How to handle citations in the UI
The content
of the bot message will have inline-citations in the format of [^int]
where int
corresponds to the citationNumber
in the ChatCitation
object.
To show this in the UX, you can use a regex to extract the inline citations and replace them with the URL of the source as see in the citations
object. For example, convert [^int]
to [^int](citation[int].url)
to add footnotes with the appropriate citation URL. Try out our chat UI to see this in action.
PostChatResultSignals (preview)
If you prefer to track usage analytics in your own analytics system instead of ours, we provide analytics in the chat session response that you can use to enrich your own analytics.
Property | Type | Description |
---|---|---|
botAbleToAnswerGivenSources | Boolean | Indicates if the bot was able to answer given sources. |
featureNotSupported | Boolean | Indicates whether the bot indicated that a feature or capability is not currently supported. |
suggestedFollowupQuestions | [String!] | Suggested follow-up questions based on the user question and bot answer |
Please note that this feature is currently in preview, if you'd like this enabled for your organization, please contact us at support@inkeep.com to enable it for your organization.