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.6 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { guideliteAuth } from '../common/auth';
import { HttpMethod } from '@activepieces/pieces-common';
import { makeRequest } from '../common/client';
import { assistantIdDropdown } from '../common/props';

export const sendAPrompt = createAction({
  auth: guideliteAuth,
  name: 'sendAPrompt',
  displayName: 'Send a Prompt',
  description: 'Send a message to a Guidelite Assistant',
  audience: 'both',
  aiMetadata: { description: 'Sends a message to a specified GuideLite AI assistant and returns its reply. Provide a conversationId to continue an existing conversation, or omit it to start a new one. Each call posts a new message and produces a fresh assistant response, so it is not idempotent.', idempotent: false },
  props: {
    assistantId: assistantIdDropdown,
    message: Property.LongText({
      displayName: 'Message',
      description: 'The input message to be processed by the assistant',
      required: true,
    }),
    conversationId: Property.ShortText({
      displayName: 'Conversation ID',
      description:
        'The Conversation ID of the previous conversation. If empty, a new conversation will be created',
      required: false,
    }),
  },
  async run(context) {
    const { assistantId, message, conversationId } = context.propsValue;

    const body: any = {
      assistantId,
      message,
    };

    if (conversationId) {
      body.conversationId = conversationId;
    }
    const response = await makeRequest(
      context.auth,
      HttpMethod.POST,
      `/interface-assistant/chat`,
      body
    );

    return response.body;
  },
});