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
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import {
TriggerStrategy,
createTrigger,
PiecePropValueSchema,
AppConnectionValueForAuthProperty,
} from '@activepieces/pieces-framework';
import { quickbooksAuth } from '../lib/auth';
import dayjs from 'dayjs';
import {
DedupeStrategy,
Polling,
pollingHelper,
} from '@activepieces/pieces-common';
import { quickbooksQuery, QuickbooksEntityResponse } from '../lib/common';
import { QuickbooksInvoice } from '../lib/types';
const polling: Polling<
AppConnectionValueForAuthProperty<typeof quickbooksAuth>,
Record<string, unknown>
> = {
strategy: DedupeStrategy.TIMEBASED,
async items({ auth, lastFetchEpochMS }) {
const { access_token } = auth;
const companyId = auth.props?.['companyId'] as string;
const query =
lastFetchEpochMS === 0
? `SELECT * FROM Transfer ORDERBY Metadata.CreateTime DESC MAXRESULTS 10`
: `SELECT * FROM Transfer WHERE Metadata.CreateTime >= '${dayjs(
lastFetchEpochMS
).toISOString()}' ORDERBY Metadata.CreateTime DESC`;
// https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/transfer#query-a-transfer
const response = await quickbooksQuery<
QuickbooksEntityResponse<QuickbooksInvoice>
>({
accessToken: access_token,
companyId,
query,
});
const transers = response.QueryResponse?.['Transfer'] ?? [];
return transers.map((transfer) => ({
epochMilliSeconds: dayjs(transfer.MetaData?.CreateTime).valueOf(),
data: transfer,
}));
},
};
export const newTransfer = createTrigger({
auth: quickbooksAuth,
name: 'new_transfer',
classification: 'READ',
displayName: 'New Transfer',
description:
'Triggers when a Transfer is created.',
aiMetadata: {
description: 'Fires when a new transfer is created in the connected QuickBooks company, emitting the newly created transfer record. Use to react to funds being moved between two accounts.',
},
props: {},
type: TriggerStrategy.POLLING,
async onEnable(context) {
await pollingHelper.onEnable(polling, context);
},
async onDisable(context) {
await pollingHelper.onDisable(polling, context);
},
async test(context) {
return await pollingHelper.test(polling, context);
},
async run(context) {
return await pollingHelper.poll(polling, context);
},
sampleData: undefined,
});