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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import {
httpClient,
HttpMethod,
AuthenticationType,
} from '@activepieces/pieces-common';
import { dropboxAuth } from '../auth';
import { downloadFileOutputSchema } from '../output-schemas';
export const dropboxDownloadFile = createAction({
auth: dropboxAuth,
name: 'downloadFile',
classification: 'READ',
displayName: 'Download File',
description: 'Download a file from Dropbox',
audience: 'both',
aiMetadata: { description: 'Downloads the file at the given Dropbox path and returns it as a file object for use by later steps. Use to retrieve file contents into a flow. Read-only on Dropbox; repeating the call with the same path is safe and yields the same file.', idempotent: true },
outputSchema: downloadFileOutputSchema,
props: {
path: Property.ShortText({
displayName: "Path",
description: "Path of the file to download.",
placeholder: "/Reports/q1.pdf",
required: true
})
},
async run(context) {
// Capture file name, if unsuccesfull default to output.pdf
const fileName = (context.propsValue.path.match(/[^/]+$/) ?? ['output.pdf'])[0]
// For information about Dropbox JSON encoding, see https://www.dropbox.com/developers/reference/json-encoding
const dropboxApiArg = JSON.stringify({path:context.propsValue.path}).replace(/[\u007f-\uffff]/g, (c) => '\\u'+('000'+c.charCodeAt(0).toString(16)).slice(-4));
const result = await httpClient.sendRequest({
method: HttpMethod.POST,
url: `https://content.dropboxapi.com/2/files/download`,
headers: {
'Content-Type': 'application/octet-stream',
'Dropbox-API-Arg': dropboxApiArg
},
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: context.auth.access_token,
},
responseType:'stream'
});
return {
file: await context.files.write({
fileName: fileName,
data: result.body
})
}
},
});