Overview
This node listens to messages from a specified Google Cloud Pub/Sub topic and subscription. It is useful for workflows that need to react to real-time messages published to a Pub/Sub topic, such as processing event notifications, integrating with other systems, or triggering downstream automation based on message content. For example, it can be used to listen for new user sign-up events or order updates and then process those events automatically within n8n.
Use Case Examples
- Listening to a Pub/Sub topic for new messages and automatically processing them in a workflow.
- Decoding JSON message data from Pub/Sub and using it to update a database or send notifications.
Properties
| Name | Meaning |
|---|---|
| Project ID | Google Cloud project id where the Pub/Sub topic resides. |
| Topic | Name of the Google Pub/Sub topic to listen to for messages. |
| Subscription | Name of the Pub/Sub subscription for this topic and node. It will be created if it doesn't exist. |
| Acknowledge Messages | Whether to acknowledge the received messages after processing to prevent re-delivery. |
| Decode JSON | If enabled, automatically decode the message data from JSON format. |
Output
JSON
id- The unique identifier of the received Pub/Sub message.data- The content of the message, either as a decoded JSON object or raw string depending on the 'Decode JSON' setting.attributes- Additional attributes associated with the Pub/Sub message.
Dependencies
- Google Cloud Pub/Sub API
- Google Auth Library
Troubleshooting
- Ensure that the provided Google Cloud project ID, topic, and subscription names are correct and that the service account credentials have the necessary Pub/Sub permissions.
- If messages are not received, verify that the topic and subscription exist or allow the node to create them automatically.
- If JSON decoding fails, check that the message data is valid JSON and that 'Decode JSON' is enabled only when appropriate.
- Timeout error during manual trigger execution indicates no message was received within 30 seconds; this timeout does not apply to active workflows which listen indefinitely.
Links
- Google Cloud Pub/Sub Documentation - Official documentation for Google Cloud Pub/Sub client libraries and usage.
- Google Cloud Pub/Sub Subscriber Guide - Guide on managing subscriptions and receiving messages from Pub/Sub topics.
