Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.2 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { timelinesAiAuth, timelinesAiCommon } from '../common';

export const findUploadedFile = createAction({
  auth: timelinesAiAuth,
  name: 'findUploadedFile',
  classification: 'SEARCH',
  displayName: 'Find Uploaded File',
  description: 'Locate an uploaded file by filename or identifier.',
  audience: 'both',
  aiMetadata: { description: 'Lists files previously uploaded to TimelinesAI, optionally filtered by filename; with no filename it returns all uploaded files. Use to find a file and its uid before attaching it to a chat message. Read-only and idempotent.', idempotent: true },
  props: {
    filename: Property.ShortText({
      displayName: 'Filename',
      description: 'The name of the uploaded file to search for.',
      required: false,
    }),
  },
  async run({ auth: apiKey, propsValue: { filename } }) {
    const response = await timelinesAiCommon.listUploadedFiles({
      apiKey,
      filename,
    });
    if (response.status !== 'ok') {
      throw new Error(
        `Error fetching uploaded files: ${response.message || 'Unknown error'}`
      );
    }
    return response.data;
  },
});