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.4 KB
Raw Blame
import { Property, createAction } from '@activepieces/pieces-framework';
import { onfleetAuth } from '../..';
import { common } from '../common';

import Onfleet from '@onfleet/node-onfleet';

export const createTeam = createAction({
  auth: onfleetAuth,
  name: 'create_team',
  displayName: 'Create Team',
  description: 'Create a new team',
  audience: 'both',
  aiMetadata: { description: 'Creates a new Onfleet team with a name and optional workers, managers, hub, and self-assignment setting. Not idempotent: calling it repeatedly creates duplicate teams. Use update-team to modify an existing team.', idempotent: false },
  props: {
    name: Property.ShortText({
      displayName: 'Name',
      description: 'Name of the team',
      required: true,
    }),
    workers: common.workers,
    managers: common.managers,
    hub: common.hubOptional,
    enableSelfAssignment: Property.Checkbox({
      displayName: 'Enable Self Assignment',
      description:
        'Allows Drivers to Self Assign Tasks that are in the Team unassigned container.',
      required: false,
    }),
  },
  async run(context) {
    const onfleetApi = new Onfleet(context.auth.secret_text);

    return await onfleetApi.teams.create({
      name: context.propsValue.name,
      workers: context.propsValue.workers,
      managers: context.propsValue.managers,
      hub: context.propsValue.hub,
      enableSelfAssignment: context.propsValue.enableSelfAssignment,
    });
  },
});