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.3 KB
Raw Blame
import { HttpMethod } from '@activepieces/pieces-common';
import { createAction, Property } from '@activepieces/pieces-framework';
import { sliteAuth } from '../auth';
import { sliteApi } from '../common/client';
import { sliteProps } from '../common/props';
import { SliteSearchResponse } from '../common/types';

export const sliteSearchDocsAction = createAction({
  auth: sliteAuth,
  name: 'search_docs',
  displayName: 'Search Docs',
  description: 'Performs a keyword search across the docs you have access to.',
  audience: 'both',
  aiMetadata: {
    description:
      'Runs a keyword search across the Slite docs the connected account can access, with optional scoping to a parent doc id, inclusion of archived docs, and pagination. Use this for term/title matching to locate docs and their ids; for natural-language question answering use Ask Question instead. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    query: Property.ShortText({
      displayName: 'Search Term',
      description: 'The keywords to search for.',
      required: true,
    }),
    parent_note_id: sliteProps.noteId({
      required: false,
      displayName: 'Parent Doc',
      description: 'Limit results to docs nested under this parent.',
    }),
    include_archived: Property.Checkbox({
      displayName: 'Include Archived',
      description: 'Also search archived docs.',
      required: false,
      defaultValue: false,
    }),
    hits_per_page: Property.Number({
      displayName: 'Results Per Page',
      description: 'How many results to return per page (1–100).',
      required: false,
      defaultValue: 25,
    }),
    page: Property.Number({
      displayName: 'Page',
      description: 'Which page of results to return (starts at 0).',
      required: false,
      defaultValue: 0,
    }),
  },
  async run(context) {
    const { query, parent_note_id, include_archived, hits_per_page, page } =
      context.propsValue;
    const response = await sliteApi.call<SliteSearchResponse>({
      apiKey: context.auth.secret_text,
      method: HttpMethod.GET,
      resourceUri: '/search-notes',
      query: {
        query,
        parentNoteId: parent_note_id,
        includeArchived: include_archived,
        hitsPerPage: hits_per_page,
        page,
      },
    });
    return response;
  },
});