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 { createTrigger, TriggerStrategy } from '@activepieces/pieces-framework';
import { timelinesAiAuth, timelinesAiCommon } from '../common';
import { WebhookInformation } from '../common/types';
export const newOutgoingChat = createTrigger({
auth: timelinesAiAuth,
name: 'newOutgoingChat',
classification: 'READ',
displayName: 'New Outgoing Chat',
description: 'Fires when a new outgoing chat is initiated.',
aiMetadata: {
description: 'Fires when a new outgoing TimelinesAI WhatsApp chat is initiated, i.e. the connected account starts a conversation with a contact. Represents the start of an outbound conversation, carrying the chat and WhatsApp account details.',
},
props: {},
sampleData: {
event_type: 'chat:new',
chat: {
id: 123456,
name: 'John Smith',
phone: '+123456789',
jid: '[email protected]',
is_group: false,
closed: false,
read: false,
labels: ['string'],
unattended_customer: false,
chatgpt_autoresponse_enabled: false,
whatsapp_account_id: '[email protected]',
chat_url: 'https://app.timelines.ai/chat/123456/messages/',
created_timestamp: '2024-01-08 10:35:18 +0200',
last_message_uid: 'afa9d4dd-978d-4a14-aa1b-bd65c272e645',
last_message_timestamp: '2024-01-08 10:35:18 +0200',
responsible_name: 'Agent Brown',
responsible_email: '[email protected]',
previous_responsible_name: 'Agent Jones',
previous_responsible_email: '[email protected]',
},
whatsapp_account: {
id: '[email protected]',
phone: '+123456789',
connected_on: '2024-01-08 10:35:18 +0200',
disconnected_on: '2024-01-08 10:35:18 +0200',
status: 'active',
account_name: 'Some account',
owner_name: 'Agent Smith',
owner_email: '[email protected]',
},
},
type: TriggerStrategy.WEBHOOK,
async onEnable(context) {
const response = await timelinesAiCommon.createWebhook({
apiKey: context.auth,
event_type: 'chat:outgoing:new',
url: context.webhookUrl,
enabled: true,
});
await context.store.put<WebhookInformation>('_new_outgoing_chat', {
webhook_id: response.data.id,
});
},
async onDisable(context) {
const webhookInfo = await context.store.get<WebhookInformation>(
'_new_outgoing_chat'
);
const webhook_id = webhookInfo?.webhook_id;
if (webhook_id) {
await timelinesAiCommon.deleteWebhook({
apiKey: context.auth,
webhook_id: webhook_id as number,
});
}
},
async run(context) {
return [context.payload.body];
},
});