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.6 KB
Raw Blame
import {
  createCustomApiCallAction,
  httpClient,
  HttpMethod,
  AuthenticationType,
} from '@activepieces/pieces-common';
import { createPiece, PieceAuth } from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/pieces-framework';

import { listTestimonialsAction } from './lib/actions/list-testimonials';
import { getTestimonialAction } from './lib/actions/get-testimonial';
import { createTestimonialAction } from './lib/actions/create-testimonial';
import { updateTestimonialAction } from './lib/actions/update-testimonial';
import { deleteTestimonialAction } from './lib/actions/delete-testimonial';
import { findTestimonialsAction } from './lib/actions/find-testimonials';
import { fetchTestimonialAction } from './lib/actions/fetch-testimonial';
import { addTestimonialAction } from './lib/actions/add-testimonial';
import { modifyTestimonialAction } from './lib/actions/modify-testimonial';
import { removeTestimonialAction } from './lib/actions/remove-testimonial';
import { testimonialEventTrigger } from './lib/triggers/testimonial-event';
import { SENJA_BASE_URL } from './lib/common';

export const senjaAuth = PieceAuth.SecretText({
  displayName: 'API Key',
  description: `To get your Senja API key:
1. Log in to your Senja account.
2. Go to **Automate** in the left sidebar.
3. Click **REST API** and copy your API key.`,
  required: true,
  validate: async ({ auth }) => {
    try {
      await httpClient.sendRequest({
        method: HttpMethod.GET,
        url: `${SENJA_BASE_URL}/testimonials`,
        authentication: {
          type: AuthenticationType.BEARER_TOKEN,
          token: auth,
        },
        queryParams: { limit: '1' },
      });
      return { valid: true };
    } catch {
      return { valid: false, error: 'Invalid API Key. Please check and try again.' };
    }
  },
});

export const senja = createPiece({
  displayName: 'Senja',
  description: 'Collect, manage, and share testimonials with Senja.',
  minimumSupportedRelease: '0.87.0',
  logoUrl: 'https://cdn.activepieces.com/pieces/senja.png',
  categories: [PieceCategory.MARKETING],
  auth: senjaAuth,
  authors: ['bst1n', 'onyedikachi-david'],
  actions: [
    listTestimonialsAction,
    getTestimonialAction,
    createTestimonialAction,
    updateTestimonialAction,
    deleteTestimonialAction,
    findTestimonialsAction,
    fetchTestimonialAction,
    addTestimonialAction,
    modifyTestimonialAction,
    removeTestimonialAction,
    createCustomApiCallAction({
      baseUrl: () => SENJA_BASE_URL,
      auth: senjaAuth,
      authMapping: async (auth) => ({
        Authorization: `Bearer ${auth}`,
      }),
    }),
  ],
  triggers: [testimonialEventTrigger],
});