AI · GraphQL query

aiThreadCreate query

Creates an AI chat thread of the requested type, or returns the existing one: a thread id is derived from the user, organization, thread type, object type, and object id, so repeating a call returns the same thread with its history. The search- and GraphQL-generation types require an object type, and the object question type also requires an object id. Send messages to it with aiThreadMessage.

Response

Returns an AiThread!

Arguments

Name Description
orgId - OrganizationId! The Organization identifier.
options - AiThreadCreateInput! Configuration options for creating the AI chat thread, including thread type and other optional settings.

Example

Query

query aiThreadCreate(
  $orgId: OrganizationId!,
  $options: AiThreadCreateInput!
) {
  aiThreadCreate(
    orgId: $orgId,
    options: $options
  ) {
    id
    name
    threadType
    objectId
    entries {
      timestamp
      isFromUser
      message
    }
    timestamp
  }
}

Variables

{
  "orgId": "615f3b3b28284380e28a7342",
  "options": AiThreadCreateInput
}

Response

{
  "data": {
    "aiThreadCreate": {
      "id": AiThreadId,
      "name": "xyz789",
      "threadType": "GENERAL",
      "objectId": "abc123",
      "entries": [AiThreadEntry],
      "timestamp": "2021-10-07T18:23:25.829Z"
    }
  }
}

Related operations

  • aiThread query: Retrieves one of the caller's AI chat threads with its messages.
  • aiThreadClear query: Removes every message from one of the caller's AI chat threads and returns the now-empty thread.
  • aiThreads query: Lists the caller's AI chat threads in an organization that contain at least one message, most recently updated first.