Ai Tasks

An AI Task defines a Files.com AI prompt that can run on a schedule or in response to file actions.

List Ai Tasks

SDK Method

aitask.List()

Return Object

[]*AiTask

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"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

aiTaskIterator, err := ai_task.List(files_sdk.AiTaskListParams{})
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 aiTaskIterator.Next() {
    aiTask := aiTaskIterator.aiTask()
}
err = aiTaskIterator.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 Ai Task

SDK Method

aitask.Find()

Return Object

AiTask

Authorization Requirement

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

AiTaskFindParams Fields

FieldDescription
Id
int64
Required
Ai Task ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

aiTask, err := ai_task.Find(files_sdk.AiTaskFindParams{Id: 1})
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())
    }
}

Create Ai Task

SDK Method

aitask.Create()

Return Object

AiTask

Authorization Requirement

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

AiTaskCreateParams Fields

FieldDefaultDescription
Description
string
AI Task description.
Disabled
boolean
falseIf true, this AI Task will not run.
HolidayRegion
string
Optional holiday region used by the AI Task schedule.
Interval
string
If trigger is daily, this specifies how often to run the AI Task.
Name
string
Required
AI Task name.
Path
string
""Path scope used for action-triggered AI Tasks.
PermissionSet
string
"full"Permissions used by the internal API key for this AI Task. Valid values are full and files_only.
Possible values: full, files_only
Prompt
string
Required
Prompt sent when this AI Task is invoked.
RecurringDay
int64
If trigger is daily, this selects the day number inside the chosen interval.
RecurringDays
array(int64)
If trigger is daily, this selects one or more day numbers inside a week, month, quarter, or year interval.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the AI Task's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, the 0-based weekdays used by the schedule.
ScheduleTimeZone
string
Time zone used by the AI Task schedule.
ScheduleTimesOfDay
array(string)
Times of day in HH:MM format for the AI Task schedule.
Source
string
"*"Source glob used with path for action-triggered AI Tasks.
Trigger
string
"manual"How this AI Task is triggered.
Possible values: manual, daily, custom_schedule, action
TriggerActions
array(string)
If trigger is action, the file action types that invoke this AI Task. Valid actions are create, copy, move, archived_delete, update, read, destroy.
WorkspaceId
int64
0Workspace ID. 0 means the default workspace.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

aiTask, err := ai_task.Create(files_sdk.AiTaskCreateParams{
  Name: "Summarize daily reports",
  Prompt: "Summarize the uploaded file and identify follow-up actions."
})
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())
    }
}

Manually Run AI Task

SDK Method

aitask.ManualRun()

Return Object

No return value.

Authorization Requirement

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

AiTaskManualRunParams Fields

FieldDescription
Id
int64
Required
Ai Task ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

err := ai_task.ManualRun(files_sdk.AiTaskManualRunParams{Id: 1})
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())
    }
}

Update Ai Task

SDK Method

aitask.Update()

Return Object

AiTask

Authorization Requirement

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

AiTaskUpdateParams Fields

FieldDescription
Id
int64
Required
Ai Task ID.
Description
string
AI Task description.
Disabled
boolean
If true, this AI Task will not run.
HolidayRegion
string
Optional holiday region used by the AI Task schedule.
Interval
string
If trigger is daily, this specifies how often to run the AI Task.
Name
string
AI Task name.
Path
string
Path scope used for action-triggered AI Tasks.
PermissionSet
string
Permissions used by the internal API key for this AI Task. Valid values are full and files_only.
Possible values: full, files_only
Prompt
string
Prompt sent when this AI Task is invoked.
RecurringDay
int64
If trigger is daily, this selects the day number inside the chosen interval.
RecurringDays
array(int64)
If trigger is daily, this selects one or more day numbers inside a week, month, quarter, or year interval.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the AI Task's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, the 0-based weekdays used by the schedule.
ScheduleTimeZone
string
Time zone used by the AI Task schedule.
ScheduleTimesOfDay
array(string)
Times of day in HH:MM format for the AI Task schedule.
Source
string
Source glob used with path for action-triggered AI Tasks.
Trigger
string
How this AI Task is triggered.
Possible values: manual, daily, custom_schedule, action
TriggerActions
array(string)
If trigger is action, the file action types that invoke this AI Task. Valid actions are create, copy, move, archived_delete, update, read, destroy.
WorkspaceId
int64
Workspace ID. 0 means the default workspace.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

aiTask, err := ai_task.Update(files_sdk.AiTaskUpdateParams{
  Id: 1,
  Description: "Summarizes files uploaded by the accounting team."
})
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())
    }
}

Delete Ai Task

SDK Method

aitask.Delete()

Return Object

No return value.

Authorization Requirement

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

AiTaskDeleteParams Fields

FieldDescription
Id
int64
Required
Ai Task ID.

Example Request

import (
    "fmt"
    "errors"

    files_sdk "github.com/Files-com/files-sdk-go/v3"
    ai_task "github.com/Files-com/files-sdk-go/v3/aitask"
)

err := ai_task.Delete(files_sdk.AiTaskDeleteParams{Id: 1})
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 AiTask Object

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

AttributeDescription
Id
int64
AI Task ID.
WorkspaceId
int64
Workspace ID. 0 means the default workspace.
Name
string
AI Task name.
Description
string
AI Task description.
Prompt
string
Prompt sent when this AI Task is invoked.
PermissionSet
string
Permissions used by the internal API key for this AI Task. Valid values are full and files_only.
Possible values: full, files_only
Path
string
Path scope used for action-triggered AI Tasks. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
Source
string
Source glob used with path for action-triggered AI Tasks.
Disabled
boolean
If true, this AI Task will not run.
Trigger
string
How this AI Task is triggered.
Possible values: manual, daily, custom_schedule, action
TriggerActions
array(string)
If trigger is action, the file action types that invoke this AI Task. Valid actions are create, copy, move, archived_delete, update, read, destroy.
Interval
string
If trigger is daily, this specifies how often to run the AI Task.
RecurringDay
int64
If trigger is daily, this selects the day number inside the chosen interval.
RecurringDays
array(int64)
If trigger is daily, this selects one or more day numbers inside a week, month, quarter, or year interval.
ScheduleId
int64
If trigger is custom_schedule, the reusable Schedule used instead of the AI Task's schedule fields.
ScheduleDaysOfWeek
array(int64)
If trigger is custom_schedule, the 0-based weekdays used by the schedule.
ScheduleTimesOfDay
array(string)
Times of day in HH:MM format for the AI Task schedule.
ScheduleTimeZone
string
Time zone used by the AI Task schedule.
HolidayRegion
string
Optional holiday region used by the AI Task schedule.
HumanReadableSchedule
string
Human-readable schedule description.
LastRunAt
date-time
Most recent successful invocation time.
MasterAdminUserId
int64
Master User ID used for AI Task invocations.
CreatedAt
date-time
Creation time.
UpdatedAt
date-time
Last update time.