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 { createAction, Property } from '@activepieces/pieces-framework';
import { frontAuth } from '../common/auth';
import { makeRequest } from '../common/client';
import { HttpMethod } from '@activepieces/pieces-common';
import { conversationIdDropdown, teammateIdDropdown } from '../common/dropdown';

export const assignUnassignConversation = createAction({
  auth: frontAuth,
  name: 'assignUnassignConversation',
  displayName: 'Assign/Unassign Conversation',
  description: 'Assign a conversation to a teammate or remove assignment.',
  audience: 'both',
  aiMetadata: {
    description:
      'Set or clear the assignee of a Front conversation: provide a teammate ID to assign it, or leave the assignee empty to unassign. Use for routing or ownership changes. Idempotent: assigning to the same teammate (or leaving unassigned) does not change the result.',
    idempotent: true,
  },
  props: {
    conversation_id: conversationIdDropdown,
    assignee_id: teammateIdDropdown,
  },
  async run({ auth, propsValue }) {
    const { conversation_id, assignee_id } = propsValue;
    const path = `/conversations/${conversation_id}/assignee`;
    const body: Record<string, unknown> = {};
    if (assignee_id) {
      body['assignee_id'] = assignee_id;
    }

    await makeRequest(auth, HttpMethod.PUT, path, body);
    return {
      success: true,
      message: `Conversation ${conversation_id} assignee changed successfully`,
    };
  },
});