Chat Sessions

A ChatSession represents one conversation with the Files.com AI Assistant.

List Chat Sessions

SDK Method

ChatSession.list()

Return Object

ChatSession[]

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Additional Arguments

Example Request

import ChatSession from 'files.com/lib/models/ChatSession';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const chatSessions = await ChatSession.list();
  for (const chatSession of chatSessions) {
    // Operate on chatSession
  }
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

Show Chat Session

SDK Method

ChatSession.find()

Return Object

ChatSession

Authorization Requirement

Requires either a Site-Wide API key or User API key or session from a User with Site Admin permissions.

Method Arguments

ArgumentDescription
id
string
Required
Chat Session ID.

Example Request

import ChatSession from 'files.com/lib/models/ChatSession';
import * as FilesErrors from 'files.com/lib/Errors';

try {
  const chatSession = await ChatSession.find(id);
  // Operate on chatSession
} catch (err) {
  if (err instanceof FilesErrors.NotAuthenticatedError) {
    console.error(`Authentication Error Occurred (${err.constructor.name}): ${err.error}`);
  } else if (err instanceof FilesErrors.FilesError) {
    console.error(`Unknown Error Occurred (${err.constructor.name}): ${err.error}`);
  } else {
    throw err;
  }
}

The ChatSession Object

Some of the methods above return a ChatSession object. The attributes of this object are listed below.

AttributeDescription
id
string
Chat Session ID.
title
string
Short AI-generated chat title.
user_id
int64
User ID.
ai_task_id
int64
AI Task ID. Present when the conversation was started by an AI Task.
workspace_id
int64
Workspace ID. 0 means the default workspace.
last_active_at
date-time
Most recent chat activity date/time.
created_at
date-time
Chat session creation date/time.
messages
array(object)
Visible conversation messages in this chat session. For performance reasons, this is not provided when listing chat sessions.