Skip to content

AIResource

API reference for the AI resource.

Methods

list

Get all AI suggestions for the current company.

typescript
async list(): Promise<AISuggestion[]>

accept

Accept an AI suggestion.

typescript
async accept(suggestionId: string): Promise<{ success: boolean; message: string }>

reject

Reject an AI suggestion.

typescript
async reject(suggestionId: string, reason?: string): Promise<{ success: boolean; message: string }>

updateTaskStatus

Update the status of a specific task within a suggestion.

typescript
async updateTaskStatus(
  docId: string,
  taskId: string,
  status: 'accepted' | 'rejected',
  reason?: string
): Promise<{ success: boolean; message: string }>

Types

AISuggestion

typescript
interface AISuggestion {
  id: string;
  status?: 'pending' | 'accepted' | 'rejected';
  suggested_tasks?: Array<{
    cast_id?: string;
    title?: string;
    description?: string;
    status?: 'pending' | 'accepted' | 'rejected';
    acceptedBy?: string;
    acceptedAt?: string;
    rejectedBy?: string;
    rejectedAt?: string;
    reason?: string;
  }>;
  createdAt?: string;
  acceptedBy?: string;
  acceptedAt?: string;
  rejectedBy?: string;
  rejectedAt?: string;
  rejectionReason?: string;
}

Example

typescript
// List all suggestions
const suggestions = await client.ai.list();

for (const suggestion of suggestions) {
  if (suggestion.status === 'pending') {
    console.log(`Pending suggestion: ${suggestion.id}`);
    
    // Review tasks
    for (const task of suggestion.suggested_tasks || []) {
      console.log(`  Task: ${task.title}`);
    }
    
    // Accept the suggestion
    await client.ai.accept(suggestion.id);
  }
}

Released under the MIT License.