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.5 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
import { talkableAuth } from '../../..';
import { TALKABLE_API_URL } from '../../common/constants';

export const getLoyaltyRedeemActions = createAction({
  name: 'get_loyalty_redeem_actions', // Must be a unique across the piece, this shouldn't be changed.
  classification: 'SEARCH',
  auth: talkableAuth,
  displayName: 'Get loyalty actions',
  description: 'Get array of loyalty actions',
  audience: 'both',
  aiMetadata: { description: 'Retrieve the list of loyalty redeem actions available to a Talkable loyalty member, identified by their email. Use to see what rewards a customer can redeem. Read-only; the person\'s email is required.', idempotent: true },
  props: {
    person_email: Property.ShortText({
      displayName: 'Person email',
      description: undefined,
      required: true,
    }),
  },
  async run(context) {
    const { site, api_key } = context.auth.props;
    const getLoyaltyRedeemActionsResponse = await httpClient
      .sendRequest<string[]>({
        method: HttpMethod.GET,
        url: `${TALKABLE_API_URL}/loyalty/members/${context.propsValue['person_email']}/redeem_actions`,
        headers: {
          Authorization: `Bearer ${api_key}`,
          'Content-Type': 'application/json',
        },
        queryParams: {
          site_slug: site,
        },
      });
    return getLoyaltyRedeemActionsResponse.body;
  },
});