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.2 KB
Raw Blame
import { createAction, MarkdownVariant, Property } from '@activepieces/pieces-framework';
import { stopFlowActionOutputSchema } from '../output-schemas';

export const stopFlow = createAction({
  audience: 'both',
  name: 'stopFlow',
  classification: 'READ',
  displayName: 'Stop Flow',
  description: 'Ends the run at this step and marks it as succeeded.',
  aiMetadata: { description: 'Ends the current flow run at this step and marks it as stopped rather than failed, so no later steps execute. Use it for an early exit when a condition means there is nothing left to do; prefer Fail Flow when the exit should be recorded as an error instead. Takes no inputs and stops the run without a custom webhook response; idempotent, since it drives the run to the same stopped end state and creates nothing.', idempotent: true },
  props: {
    info: Property.MarkDown({
      value: 'The run ends here and is marked as succeeded. Steps after this one do not run.',
      variant: MarkdownVariant.INFO,
    }),
  },
  outputSchema: stopFlowActionOutputSchema,
  async run(context) {
    context.run.stop();

    return {
      success: true,
      message: 'Flow stopped successfully.',
    };
  },
});