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 { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { simplirouteAuth } from '../../auth';
import { API_BASE_URL, commonHeaders } from '../../common/constants';

export const get_visit_detail = createAction({
    name: 'get_visit_detail',
    auth: simplirouteAuth,
    displayName: 'Get Visit Detail',
    description: 'Get detailed information about a specific visit.',
    audience: 'both',
    aiMetadata: { description: 'Fetch the extended detail view of one visit by ID. Read-only and idempotent; pick this over get-visit when you need the fuller plan-level detail payload rather than the basic visit record.', idempotent: true },
    props: {
        visit_id: Property.Number({ 
            displayName: 'visit_id', 
            description: 'ID of the visit to get details for.', 
            required: true 
        }),
    },
    async run(context) {
        const url = `${API_BASE_URL}/v1/plans/visits/${context.propsValue.visit_id}/detail/`;
        const response = await httpClient.sendRequest({
            method: HttpMethod.GET,
            url,
            headers: {
                ...commonHeaders,
                'Authorization': `Token ${context.auth.secret_text}`
            }
        });
        return {
            status: response.status,
            data: response.body
        };
    },
});