Add Activepieces integration for workflow automation
- Add Activepieces fork with SmoothSchedule custom piece - Create integrations app with Activepieces service layer - Add embed token endpoint for iframe integration - Create Automations page with embedded workflow builder - Add sidebar visibility fix for embed mode - Add list inactive customers endpoint to Public API - Include SmoothSchedule triggers: event created/updated/cancelled - Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { createPiece } from '@activepieces/pieces-framework';
|
||||
import { greenptAuth } from './lib/common/auth';
|
||||
import { chatCompletion } from './lib/actions/chat-completion';
|
||||
import { createEmbeddings } from './lib/actions/create-embeddings';
|
||||
import { transcribeAudio } from './lib/actions/transcribe-audio';
|
||||
import { createCustomApiCallAction } from '@activepieces/pieces-common';
|
||||
import { PieceCategory } from '@activepieces/shared';
|
||||
|
||||
export const greenpt = createPiece({
|
||||
displayName: 'GreenPT',
|
||||
description:
|
||||
'GreenPT is a green AI and privacy friendly GPT-powered chat platform',
|
||||
auth: greenptAuth,
|
||||
minimumSupportedRelease: '0.36.1',
|
||||
logoUrl: 'https://cdn.activepieces.com/pieces/greenpt.png',
|
||||
authors: ['sanket-a11y'],
|
||||
categories: [PieceCategory.ARTIFICIAL_INTELLIGENCE],
|
||||
actions: [
|
||||
chatCompletion,
|
||||
createEmbeddings,
|
||||
transcribeAudio,
|
||||
createCustomApiCallAction({
|
||||
auth: greenptAuth,
|
||||
baseUrl: () => `https://api.greenpt.ai/v1`,
|
||||
authMapping: async (auth) => {
|
||||
return {
|
||||
Authorization: `Bearer ${auth.secret_text}`,
|
||||
};
|
||||
},
|
||||
}),
|
||||
],
|
||||
triggers: [],
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { greenptAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const chatCompletion = createAction({
|
||||
auth: greenptAuth,
|
||||
name: 'chatCompletion',
|
||||
displayName: 'Ask GreenPT',
|
||||
description: '',
|
||||
props: {
|
||||
model: Property.StaticDropdown({
|
||||
displayName: 'Model',
|
||||
description: 'The model to use ',
|
||||
required: true,
|
||||
options: {
|
||||
disabled: false,
|
||||
options: [
|
||||
{
|
||||
label: 'Green L',
|
||||
value: 'green-l',
|
||||
},
|
||||
{
|
||||
label: 'Green L Raw',
|
||||
value: 'green-l-raw',
|
||||
},
|
||||
{
|
||||
label: 'Green R',
|
||||
value: 'green-r',
|
||||
},
|
||||
{
|
||||
label: 'Green R Raw',
|
||||
value: 'green-r-raw',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
messages: Property.LongText({
|
||||
displayName: 'Message',
|
||||
description: 'Message to send',
|
||||
required: true,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { model, messages } = context.propsValue;
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
'/chat/completions',
|
||||
{
|
||||
model,
|
||||
messages: [{ role: 'user', content: messages }],
|
||||
stream: false,
|
||||
}
|
||||
);
|
||||
|
||||
return response.choices[0].message.content;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
import { greenptAuth } from '../common/auth';
|
||||
import { makeRequest } from '../common/client';
|
||||
import { HttpMethod } from '@activepieces/pieces-common';
|
||||
|
||||
export const createEmbeddings = createAction({
|
||||
auth: greenptAuth,
|
||||
name: 'createEmbeddings',
|
||||
displayName: 'Create Embeddings',
|
||||
description:
|
||||
'Generate embeddings for text input using GreenPT models for semantic search and similarity matching',
|
||||
props: {
|
||||
input: Property.LongText({
|
||||
displayName: 'Input Text',
|
||||
description:
|
||||
'Input text to embed. Can be a single string or multiple texts separated by newlines',
|
||||
required: true,
|
||||
}),
|
||||
encoding_format: Property.StaticDropdown({
|
||||
displayName: 'Encoding Format',
|
||||
description: 'The format to return the embeddings in',
|
||||
required: false,
|
||||
defaultValue: 'float',
|
||||
options: {
|
||||
disabled: false,
|
||||
options: [
|
||||
{
|
||||
label: 'Float',
|
||||
value: 'float',
|
||||
},
|
||||
{
|
||||
label: 'Base64',
|
||||
value: 'base64',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const { input, encoding_format } = context.propsValue;
|
||||
|
||||
const inputData = input.includes('\n')
|
||||
? input.split('\n').filter((line) => line.trim().length > 0)
|
||||
: input;
|
||||
|
||||
const response = await makeRequest(
|
||||
context.auth.secret_text,
|
||||
HttpMethod.POST,
|
||||
'/embeddings',
|
||||
{
|
||||
model: 'green-embedding',
|
||||
input: inputData,
|
||||
encoding_format: encoding_format,
|
||||
}
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,140 @@
|
||||
import { createAction, Property } from '@activepieces/pieces-framework';
|
||||
|
||||
import { httpClient, HttpMethod } from '@activepieces/pieces-common';
|
||||
import { greenptAuth } from '../common/auth';
|
||||
|
||||
export const transcribeAudio = createAction({
|
||||
auth: greenptAuth,
|
||||
name: 'transcribeAudio',
|
||||
displayName: 'Transcribe Audio',
|
||||
description:
|
||||
'Transcribe pre-recorded audio files with speaker diarization and advanced features',
|
||||
props: {
|
||||
audioUrl: Property.File({
|
||||
displayName: 'Audio File',
|
||||
description: 'Audio file to transcribe (WAV, MP3, FLAC, etc.)',
|
||||
required: true,
|
||||
}),
|
||||
model: Property.StaticDropdown({
|
||||
displayName: 'Model',
|
||||
description: 'Speech-to-text model to use',
|
||||
required: false,
|
||||
defaultValue: 'green-s',
|
||||
options: {
|
||||
disabled: false,
|
||||
options: [
|
||||
{
|
||||
label: 'Green S',
|
||||
value: 'green-s',
|
||||
},
|
||||
{
|
||||
label: 'Green S Pro',
|
||||
value: 'green-s-pro',
|
||||
},
|
||||
],
|
||||
},
|
||||
}),
|
||||
language: Property.ShortText({
|
||||
displayName: 'Language',
|
||||
description:
|
||||
'Language code (e.g., en, fr, de). Auto-detected if not specified',
|
||||
required: false,
|
||||
}),
|
||||
diarize: Property.Checkbox({
|
||||
displayName: 'Speaker Diarization',
|
||||
description: 'Enable speaker diarization to identify different speakers',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
punctuate: Property.Checkbox({
|
||||
displayName: 'Punctuate',
|
||||
description: 'Add punctuation and capitalization to transcript',
|
||||
required: false,
|
||||
defaultValue: true,
|
||||
}),
|
||||
smart_format: Property.Checkbox({
|
||||
displayName: 'Smart Format',
|
||||
description:
|
||||
'Apply formatting to transcript output for improved readability',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
filler_words: Property.Checkbox({
|
||||
displayName: 'Include Filler Words',
|
||||
description: 'Include filler words like "uh" and "um" in transcript',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
numerals: Property.Checkbox({
|
||||
displayName: 'Convert Numerals',
|
||||
description: 'Convert numbers from written format to numerical format',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
sentiment: Property.Checkbox({
|
||||
displayName: 'Analyze Sentiment',
|
||||
description: 'Analyze sentiment throughout the transcript',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
topics: Property.Checkbox({
|
||||
displayName: 'Detect Topics',
|
||||
description: 'Detect topics throughout the transcript',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
intents: Property.Checkbox({
|
||||
displayName: 'Recognize Intents',
|
||||
description: 'Recognize speaker intent throughout the transcript',
|
||||
required: false,
|
||||
defaultValue: false,
|
||||
}),
|
||||
},
|
||||
async run(context) {
|
||||
const {
|
||||
audioUrl,
|
||||
model,
|
||||
language,
|
||||
diarize,
|
||||
punctuate,
|
||||
smart_format,
|
||||
filler_words,
|
||||
numerals,
|
||||
sentiment,
|
||||
topics,
|
||||
intents,
|
||||
} = context.propsValue;
|
||||
|
||||
const queryParams = new URLSearchParams();
|
||||
if (model) {
|
||||
queryParams.append('model', model);
|
||||
}
|
||||
if (language) {
|
||||
queryParams.append('language', language);
|
||||
}
|
||||
if (diarize) queryParams.append('diarize', 'true');
|
||||
if (punctuate) queryParams.append('punctuate', 'true');
|
||||
if (smart_format) queryParams.append('smart_format', 'true');
|
||||
if (filler_words) queryParams.append('filler_words', 'true');
|
||||
if (numerals) queryParams.append('numerals', 'true');
|
||||
if (sentiment) queryParams.append('sentiment', 'true');
|
||||
if (topics) queryParams.append('topics', 'true');
|
||||
if (intents) queryParams.append('intents', 'true');
|
||||
|
||||
const url = `https://api.greenpt.ai/v1/listen?${queryParams.toString()}`;
|
||||
|
||||
const fileData = audioUrl.data;
|
||||
|
||||
const response = await httpClient.sendRequest({
|
||||
method: HttpMethod.POST,
|
||||
url: url,
|
||||
headers: {
|
||||
Authorization: `Token ${context.auth.secret_text}`,
|
||||
'Content-Type': 'audio/wav',
|
||||
},
|
||||
body: fileData,
|
||||
});
|
||||
|
||||
return response.body.results.channels[0].alternatives[0].transcript;
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import { PieceAuth } from '@activepieces/pieces-framework';
|
||||
|
||||
export const greenptAuth = PieceAuth.SecretText({
|
||||
displayName: 'API Key',
|
||||
description: 'API Key for Greenpt',
|
||||
required: true,
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import { HttpMethod, httpClient } from '@activepieces/pieces-common';
|
||||
|
||||
export const BASE_URL = `https://api.greenpt.ai/v1`;
|
||||
|
||||
export async function makeRequest(
|
||||
apikey: string,
|
||||
method: HttpMethod,
|
||||
path: string,
|
||||
body?: unknown
|
||||
) {
|
||||
try {
|
||||
const response = await httpClient.sendRequest({
|
||||
method,
|
||||
url: `${BASE_URL}${path}`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${apikey}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body,
|
||||
});
|
||||
return response.body;
|
||||
} catch (error: any) {
|
||||
throw new Error(`Unexpected error: ${error.message || String(error)}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user