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.6 KB
Raw Blame
import { docsCommon } from '../common';
import { googleDocsAuth, getAccessToken } from '../auth';
import { Property, createAction } from "@activepieces/pieces-framework";
import { documentIdProp } from '../common/props';
import { appendTextActionOutputSchema } from '../output-schemas';

export const appendText = createAction({
    auth: googleDocsAuth,
    name: 'append_text',
    classification: 'WRITE',
    description: 'Add text to the end of a document.',
    audience: 'human',
    aiMetadata: {
      description:
        'Appends text to the end of an existing Google Docs document identified by its ID. Use when an agent needs to add content to a known document without altering its existing text. Requires the document ID; not idempotent, since each call inserts the text again, accumulating duplicates.',
      idempotent: false,
    },
    displayName: 'Append Text',
    propertyGroups: [
      {
        key: 'document',
        display: 'section',
        label: 'Document',
        icon: 'file',
        props: ['documentId'],
      },
      {
        key: 'content',
        display: 'section',
        label: 'Content',
        icon: 'text',
        props: ['text'],
      },
    ],
    props: {
      documentId: documentIdProp(),
      text: Property.LongText({
        displayName: 'Text',
        description: 'Added to the end of the document.',
        required: true,
      }),
    },
    outputSchema: appendTextActionOutputSchema,
    async run(context) {
      return await docsCommon.writeToDocument(
        context.propsValue.documentId,
        context.propsValue.text,
        await getAccessToken(context.auth)
      );
    },
  });