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 { EnvelopesApi } from 'docusign-esign';
import { createAction, Property } from '@activepieces/pieces-framework';
import { docusignAuth } from '../auth';
import { createApiClient } from '../common';
export const getDocument = createAction({
name: 'getDocument',
classification: 'READ',
displayName: 'Download Document from Signing Request',
description:
'Download a document (or all documents) from a signing request as a file.',
audience: 'both',
aiMetadata: {
description:
'Downloads a document from a DocuSign envelope (signing request) as a file, given the account, envelope, and document ID. The document ID accepts a specific document number or special keywords — combined (all documents as one PDF), archive (a ZIP of all PDFs plus the certificate), certificate (only the completion certificate), or portfolio. Use to fetch signed or in-progress document files. Read-only and idempotent.',
idempotent: true,
},
auth: docusignAuth,
props: {
accountId: Property.ShortText({
displayName: 'Account ID',
required: true,
}),
envelopeId: Property.ShortText({
displayName: 'Envelope ID',
required: true,
}),
documentId: Property.ShortText({
displayName: 'Document ID',
description:
'The ID of the document to retrieve. Alternatively, you can use one of the following special keywords:\n' +
'\n' +
'combined: Retrieves all of the documents as a single PDF file. When the query parameter certificate is true, the certificate of completion is included in the PDF file. When the query parameter certificate is false, the certificate of completion is not included in the PDF file.\n' +
'archive: Retrieves a ZIP archive that contains all of the PDF documents and the certificate of completion.\n' +
'certificate: Retrieves only the certificate of completion as a PDF file.\n' +
'portfolio: Retrieves the envelope documents as a PDF portfolio.\n',
required: true,
}),
},
async run({ auth, propsValue, files }) {
const apiClient = await createApiClient(auth);
const envelopeApiClient = new EnvelopesApi(apiClient);
const filename =
propsValue.documentId === 'archive' ? 'archive.zip' : 'document.pdf';
return await files.write({
fileName: filename,
data: Buffer.from(
await envelopeApiClient.getDocument(
propsValue.accountId,
propsValue.envelopeId,
propsValue.documentId,
{}
),
'binary'
),
});
},
});