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 (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    chat_session "github.com/Files-com/files-sdk-go/v3/chatsession"
)

chatSessionIterator, err := chat_session.List(files_sdk.ChatSessionListParams{})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

for chatSessionIterator.Next() {
    chatSession := chatSessionIterator.chatSession()
}
err = chatSessionIterator.Err()
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.

ChatSessionFindParams Fields

FieldDescription
Id
string
Required
Chat Session ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    chat_session "github.com/Files-com/files-sdk-go/v3/chatsession"
)

chatSession, err := chat_session.Find(files_sdk.ChatSessionFindParams{Id: "id"})
if err != nil {
    var respErr files_sdk.ResponseError
    if errors.As(err, &respErr) {
        fmt.Println("Response Error Occurred (" + respErr.Type + "): " + respErr.ErrorMessage)
    } else {
        fmt.Printf("Unexpected Error: %s\n", err.Error())
    }
}

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.
UserId
int64
User ID.
AiTaskId
int64
AI Task ID. Present when the conversation was started by an AI Task.
WorkspaceId
int64
Workspace ID. 0 means the default workspace.
LastActiveAt
date-time
Most recent chat activity date/time.
CreatedAt
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.