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.7 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { freshserviceAuth } from '../../';
import { freshserviceApiCall } from '../common/client';
import { freshserviceCommon } from '../common/props';

export const addNoteToChange = createAction({
  auth: freshserviceAuth,
  name: 'add_note_to_change',
  classification: 'WRITE',
  displayName: 'Add Note to Change',
  description: 'Adds a private or public note to an existing change request.',
  audience: 'both',
  aiMetadata: {
    description: 'Appends a note to an existing Freshservice change request identified by change id. The note can be private (agent-only, the default) or public. Use to record commentary or an update on a change. Not idempotent — each call appends another note.',
    idempotent: false,
  },
  props: {
    change_id: freshserviceCommon.change(true),
    body: Property.LongText({
      displayName: 'Note Content',
      description: 'The content of the note. HTML is supported.',
      required: true,
    }),
    private: Property.Checkbox({
      displayName: 'Private Note',
      description: 'If checked, the note is only visible to agents. If unchecked, the requester can also see it.',
      required: false,
      defaultValue: true,
    }),
  },
  async run(context) {
    const response = await freshserviceApiCall<{ note: Record<string, unknown> }>({
      method: HttpMethod.POST,
      endpoint: `changes/${context.propsValue.change_id}/notes`,
      auth: context.auth,
      body: {
        body: context.propsValue.body,
        private: context.propsValue.private ?? true,
      },
    });

    return response.body.note;
  },
});