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 { qawafelAuth } from '../common/auth';
import { qawafelApiCall } from '../common/client';

export const getProduct = createAction({
  auth: qawafelAuth,
  name: 'get_product',
  displayName: 'Get Product',
  description:
    'Fetch a single product by its Qawafel ID. Returns the full product including price, descriptions, and active status.',
  audience: 'both',
  aiMetadata: {
    description:
      'Retrieves a single product by its Qawafel product id (the `prod_` identifier). Use when you already have a product id — from a list, trigger, or earlier step — and need its current details. Read-only and idempotent.',
    idempotent: true,
  },
  props: {
    product_id: Property.ShortText({
      displayName: 'Product ID',
      description:
        'The Qawafel product ID (starts with `prod_`). You can find this on a product page in Qawafel, in the output of "List Products", or from a webhook trigger.',
      required: true,
    }),
  },
  async run({ auth, propsValue }) {
    const response = await qawafelApiCall({
      auth,
      method: HttpMethod.GET,
      path: `/products/${propsValue.product_id}`,
    });
    return response.body;
  },
});