Trigger icon

Trigger

Trigger para receber webhooks da API da Poli

Overview

This node acts as a trigger to receive webhook events from the Poli API. It allows users to create or select an application within Poli, register a webhook URL with custom path and event subscriptions, and then listen for incoming webhook calls corresponding to those events.

Common scenarios where this node is beneficial include:

  • Automating workflows based on real-time updates from Poli, such as new messages received, message status changes, or contact updates.
  • Integrating Poli messaging or contact events into broader automation pipelines without polling.
  • Quickly setting up webhook listeners for specific Poli app events with minimal manual configuration.

Practical example:

  • A user wants to trigger an n8n workflow whenever a new message is received in their Poli-managed messaging system. They configure this node with their Poli app name, select the "Message Received" event, and specify a webhook path. When Poli sends a webhook for that event, the workflow triggers automatically.

Properties

Name Meaning
App Name The name of the Poli application to create or use for receiving webhooks.
Eventos The Poli events to monitor. Options: "Message Received", "Message Status Updated", "Contact Updated", "Contact Created". Multiple can be selected.
Webhook Path Custom path segment for the webhook URL where Poli will send event notifications.
Page (Optional) Page number when listing Poli applications, useful if many apps exist. Defaults to 1.

Output

The node outputs JSON data representing the webhook event received from Poli. The structure includes:

  • event: The event type string (e.g., "message.received").
  • timestamp: ISO timestamp of when the event was processed.
  • payload: An object containing all relevant event data fields, excluding some internal metadata keys.

Example output JSON:

{
  "event": "message.received",
  "timestamp": "2024-06-01T12:00:00.000Z",
  "payload": {
    "id": "12345",
    "content": "Hello world",
    "sender": "contact_abc",
    ...
  }
}

No binary data output is produced by this node.

Dependencies

  • Requires an API key credential for authenticating with the Poli API.
  • Needs environment variables or n8n settings defining the base webhook URL and endpoint prefix (WEBHOOK_URL and N8N_ENDPOINT_WEBHOOK), defaulting to http://localhost:5678 and webhook respectively.
  • Uses internal helper methods to make authenticated HTTP requests to Poli's REST API.

Troubleshooting

  • Missing or invalid parameters: Errors occur if required properties like "App Name", "Eventos", or "Webhook Path" are missing or invalid. Ensure these are correctly set.
  • Webhook registration failure: If the node cannot create or find the Poli app or register the webhook, it throws an error. Check API credentials and network connectivity.
  • Duplicate webhook URLs: The node checks if the webhook URL is already registered to avoid duplicates; if you change the webhook path, old webhooks may remain active until manually removed.
  • Deactivation issues: On deactivation, the node attempts to delete all webhooks for the specified app. Failure here might leave orphaned webhooks; verify permissions and API access.
  • Environment variable defaults: If WEBHOOK_URL or N8N_ENDPOINT_WEBHOOK are not set, the node falls back to localhost defaults which may not be reachable externally. Configure these properly for production use.

Links and References

Discussion