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.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { crispAuth } from '../common/auth';
import { sessionIdProp, websiteIdProp } from '../common/props';
import { crispApiCall } from '../common/client';

export const addNoteToConversationAction = createAction({
	auth: crispAuth,
	name: 'add_note',
	classification: 'WRITE',
	displayName: 'Add Note to Conversation',
	description: 'Adds an internal note to a conversation.',
	audience: 'both',
	aiMetadata: { description: 'Appends an internal operator-only note message to an existing Crisp conversation, identified by website ID and conversation session ID. Use to record private context the customer cannot see. Not idempotent: each call posts a new note.', idempotent: false },
	props: {
		websiteId: websiteIdProp,
		sessionId: sessionIdProp,
		content: Property.LongText({
			displayName: 'Note Content',
			required: true,
		}),
	},
	async run(context) {
		const { websiteId, sessionId, content } = context.propsValue;

		const response = await crispApiCall({
			auth: context.auth,
			method: HttpMethod.POST,
			resourceUri: `/website/${websiteId}/conversation/${sessionId}/message`,
			body: {
				type: 'note',
				from: 'operator',
				origin: 'chat',
				content,
			},
		});

		return response;
	},
});