Overview
This node publishes messages to a Google Cloud Pub/Sub topic. It is designed to send data from n8n workflows as messages to a specified Pub/Sub topic within a Google Cloud project. This is useful for integrating n8n with event-driven architectures, enabling workflows to trigger downstream processes or services that subscribe to the Pub/Sub topic.
Common scenarios include:
- Sending notifications or events from n8n to other systems listening on Pub/Sub.
- Integrating n8n workflows with microservices or serverless functions triggered by Pub/Sub messages.
- Streaming data updates or logs to Google Cloud infrastructure for further processing.
Example: A workflow collects sensor data and uses this node to publish each data point as a message to a Pub/Sub topic, which then triggers analytics pipelines.
Properties
| Name | Meaning |
|---|---|
| Project ID | The Google Cloud project ID where the Pub/Sub topic exists. Must be provided. |
| Topic Name | The name of the Pub/Sub topic to which messages will be published. Must be provided. |
Output
The node outputs the original input items augmented with a result field inside the json property for each item. This result contains:
success: A boolean indicating if the message was successfully published.messageId: The unique identifier assigned by Pub/Sub to the published message.
If publishing fails for an item and the node is set to continue on failure, the output item will include an error field describing the failure.
No binary data is output by this node.
Dependencies
- Requires a valid Google Cloud service account credential with permissions to publish messages to Pub/Sub topics.
- The node depends on the official
@google-cloud/pubsublibrary to interact with Google Pub/Sub. - The user must configure the node with a service account JSON key (provided via credentials) and specify the correct Project ID and Topic Name.
Troubleshooting
- Missing Project ID or Topic Name: The node throws an error if either is not provided. Ensure both are filled in.
- Invalid Service Account JSON: If the service account JSON cannot be parsed, the node will fail. Verify the credential JSON is correctly formatted.
- Permission Errors: Publishing may fail if the service account lacks Pub/Sub publisher permissions. Check IAM roles in Google Cloud Console.
- Topic Not Found: If the specified topic does not exist in the project, publishing will fail. Confirm the topic name and project ID.
- Continue On Fail Behavior: When enabled, failed items do not stop the workflow but include error details in the output for troubleshooting.