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

2.0 KB
Raw Blame
import { Property, createAction } from '@activepieces/pieces-framework';
import { clockodoCommon, makeClient, reformatDateTime } from '../../common';
import { TimeRecordEntry } from '../../common/models/entry';
import { clockodoAuth } from '../../auth';

export default createAction({
  auth: clockodoAuth,
  name: 'create_entry',
  classification: 'WRITE',
  displayName: 'Create Entry',
  description: 'Creates an entry in clockodo',
  audience: 'both',
  aiMetadata: {
    description:
      'Logs a new time-record entry in clockodo for a customer and service over a start/end time window, optionally tagged to a project, user, hourly rate, and description. Use to record tracked work after the fact; requires customer_id, service_id, and both start and end times. Not idempotent: each call creates a separate entry, so guard against duplicates.',
    idempotent: false,
  },
  props: {
    customer_id: clockodoCommon.customer_id(),
    project_id: clockodoCommon.project_id(false),
    service_id: clockodoCommon.service_id(),
    time_since: Property.DateTime({
      displayName: 'Start Time',
      required: true,
    }),
    time_until: Property.DateTime({
      displayName: 'End Time',
      required: true,
    }),
    text: Property.LongText({
      displayName: 'Description',
      required: false,
    }),
    hourly_rate: Property.Number({
      displayName: 'Hourly Rate',
      required: false,
    }),
    user_id: clockodoCommon.user_id(false),
  },
  async run({ auth, propsValue }) {
    const client = makeClient(auth.props);
    const res = await client.createEntry({
      customers_id: propsValue.customer_id,
      projects_id: propsValue.project_id,
      services_id: propsValue.service_id,
      time_since: reformatDateTime(propsValue.time_since),
      time_until: reformatDateTime(propsValue.time_until),
      text: propsValue.text,
      hourly_rate: propsValue.hourly_rate,
      users_id: propsValue.user_id,
    } as TimeRecordEntry); // For now we only support time records
    return res.entry;
  },
});