plazbot
Version:
Official Plazbot SDK for creating AI agents for WhatsApp, portals, and developers.
32 lines (31 loc) • 1.09 kB
TypeScript
import type { WebhookConfig, WebhookDefinition } from './types';
/**
* Define un webhook que genera una URL publica para recibir HTTP requests.
*
* URL generada: `https://workers.plazbot.com/<workspaceId>/<name>`
*
* Ideal para recibir eventos de Stripe, Shopify, Calendly, etc.
*
* @example
* ```typescript
* import { defineWebhook } from 'plazbot/workers';
*
* export default defineWebhook({
* name: 'stripe-payments',
* reference: 'Recibe webhooks de pagos de Stripe',
* method: 'POST',
* async handler(request, plz) {
* const event = request.body as { type: string; data: { object: any } };
* if (event.type === 'checkout.session.completed') {
* const email = event.data.object.customer_email;
* const contacts = await plz.contacts.search({ email });
* if (contacts.length > 0) {
* await plz.contacts.addTag(contacts[0].id, 'cliente-pago');
* }
* }
* return { status: 200, body: { received: true } };
* },
* });
* ```
*/
export declare function defineWebhook(config: WebhookConfig): WebhookDefinition;