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 { createAction } from '@activepieces/pieces-framework';
import {
AuthenticationType,
HttpMethod,
HttpRequest,
httpClient,
} from '@activepieces/pieces-common';
import { xeroAuth } from '../..';
import { props } from '../common/props';
export const xeroSendInvoiceEmail = createAction({
auth: xeroAuth,
name: 'xero_send_invoice_email',
classification: 'WRITE',
displayName: 'Send Sales Invoice by Email',
description: 'Sends a sales invoice via email to a contact.',
audience: 'both',
aiMetadata: {
description:
'Email an existing sales invoice to its contact via Xero, using the contact email and branding already on the invoice. Pick this to deliver an invoice that is created and ready to send. Not idempotent: each call sends the email again; the invoice must already exist and be in a sendable state.',
idempotent: false,
},
props: {
tenant_id: props.tenant_id,
invoice_id: props.sales_invoice_id(true),
},
async run(context) {
const { tenant_id, invoice_id } = context.propsValue;
const url = `https://api.xero.com/api.xro/2.0/Invoices/${invoice_id}/Email`;
const request: HttpRequest = {
method: HttpMethod.POST,
url,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: context.auth.access_token,
},
headers: {
'Xero-Tenant-Id': tenant_id,
},
};
const result = await httpClient.sendRequest(request);
// Xero returns 204 on success
if (result.status === 204) {
return { success: true };
}
return result;
},
});