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,63 @@
|
||||
import {createTrigger,TriggerStrategy, AppConnectionValueForAuthProperty,} from "@activepieces/pieces-framework";
|
||||
import {DedupeStrategy,Polling,pollingHelper,} from "@activepieces/pieces-common";
|
||||
import dayjs from "dayjs";
|
||||
import { makeRequest } from "../common/client";
|
||||
import { HttpMethod } from "@activepieces/pieces-common";
|
||||
import { AgentXAuth } from "../common/auth";
|
||||
|
||||
type Agent = {
|
||||
id: string;
|
||||
name?: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
const polling: Polling<
|
||||
AppConnectionValueForAuthProperty<typeof AgentXAuth>,
|
||||
Record<string, never>
|
||||
> = {
|
||||
strategy: DedupeStrategy.TIMEBASED,
|
||||
items: async ({ auth }) => {
|
||||
const agents = (await makeRequest(auth.secret_text, HttpMethod.GET, "/agents")) as Agent[];
|
||||
|
||||
const sortedAgents = agents.sort((a, b) =>
|
||||
dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()
|
||||
);
|
||||
|
||||
return sortedAgents.map((agent) => ({
|
||||
epochMilliSeconds: dayjs(agent.createdAt).valueOf(),
|
||||
data: agent,
|
||||
}));
|
||||
},
|
||||
};
|
||||
|
||||
export const newAgent = createTrigger({
|
||||
auth: AgentXAuth,
|
||||
name: "new_agent",
|
||||
displayName: "New Agent",
|
||||
description: "Triggers when a new AgentX agent is created.",
|
||||
props: {},
|
||||
sampleData: {
|
||||
_id: "agt_1234567890abcdef",
|
||||
name: "Customer Support Bot",
|
||||
created_at: "2025-09-08T10:00:00Z",
|
||||
},
|
||||
type: TriggerStrategy.POLLING,
|
||||
|
||||
async test(context) {
|
||||
return await pollingHelper.test(polling, context);
|
||||
},
|
||||
|
||||
async onEnable(context) {
|
||||
const { store, auth, propsValue } = context;
|
||||
await pollingHelper.onEnable(polling, { store, auth, propsValue });
|
||||
},
|
||||
|
||||
async onDisable(context) {
|
||||
const { store, auth, propsValue } = context;
|
||||
await pollingHelper.onDisable(polling, { store, auth, propsValue });
|
||||
},
|
||||
|
||||
async run(context) {
|
||||
return await pollingHelper.poll(polling, context);
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,90 @@
|
||||
import {
|
||||
createTrigger,
|
||||
TriggerStrategy,
|
||||
AppConnectionValueForAuthProperty,
|
||||
} from "@activepieces/pieces-framework";
|
||||
import {
|
||||
DedupeStrategy,
|
||||
Polling,
|
||||
pollingHelper,
|
||||
HttpMethod,
|
||||
} from "@activepieces/pieces-common";
|
||||
import dayjs from "dayjs";
|
||||
import { makeRequest } from "../common/client";
|
||||
import { AgentXAuth } from "../common/auth";
|
||||
import { AgentIdDropdown } from "../common/dropdown";
|
||||
|
||||
|
||||
type Conversation = {
|
||||
_id: string;
|
||||
type?: string;
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
const polling: Polling<
|
||||
AppConnectionValueForAuthProperty<typeof AgentXAuth>,
|
||||
{ agentId?: string }
|
||||
> = {
|
||||
strategy: DedupeStrategy.TIMEBASED,
|
||||
items: async ({ auth, propsValue }) => {
|
||||
const { agentId } = propsValue;
|
||||
|
||||
if (!agentId) {
|
||||
return [];
|
||||
}
|
||||
|
||||
try {
|
||||
const conversations = (await makeRequest(
|
||||
auth.secret_text,
|
||||
HttpMethod.GET,
|
||||
`/agents/${agentId}/conversations`
|
||||
)) as Conversation[];
|
||||
|
||||
const sortedConversations = conversations.sort((a, b) =>
|
||||
dayjs(b.createdAt).valueOf() - dayjs(a.createdAt).valueOf()
|
||||
);
|
||||
|
||||
return sortedConversations.map((conv) => ({
|
||||
epochMilliSeconds: dayjs(conv.createdAt).valueOf(),
|
||||
data: conv,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error(`Error fetching conversations for agent ${agentId}:`, error);
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const newConversation = createTrigger({
|
||||
auth: AgentXAuth,
|
||||
name: "new_conversation",
|
||||
displayName: "New Conversation",
|
||||
description: "Triggers when a new conversation begins with a specific Agent. Only detects conversations created after the trigger is enabled.",
|
||||
type: TriggerStrategy.POLLING,
|
||||
|
||||
props: {
|
||||
agentId: AgentIdDropdown,
|
||||
},
|
||||
|
||||
sampleData: {
|
||||
id: "conv_1234567890abcdef",
|
||||
type: "chat",
|
||||
created_at: "2025-09-08T11:45:00Z",
|
||||
},
|
||||
|
||||
async test(context) {
|
||||
return await pollingHelper.test(polling, context);
|
||||
},
|
||||
|
||||
async onEnable(context) {
|
||||
await pollingHelper.onEnable(polling, context);
|
||||
},
|
||||
|
||||
async onDisable(context) {
|
||||
await pollingHelper.onDisable(polling, context);
|
||||
},
|
||||
|
||||
async run(context) {
|
||||
return await pollingHelper.poll(polling, context);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user