Hi,
I have created a topic which publishes changes in my Inbox. I want to create a subscription filter which can filter based on the subject of the mail.
Is this possible?
Google Cloud Pub/Sub allows you to create subscription filters based on attributes of the messages. However, these attributes need to be set when the message is published.
The Gmail Pub/Sub notifications include certain attributes such as 'id', 'labels', 'snippet', and 'timestamp'. However, the 'subject' of the email is not directly included as an attribute in these notifications.
If you need to filter messages based on the subject of the email, you would likely need to fetch the full email message using the Gmail API after receiving the Pub/Sub notification. This would allow you to access all details of the email, including the subject.
Here's a general outline of how you could do this:
Receive the Pub/Sub notification for the new email. This notification includes the 'id' of the email.
Use the Gmail API to fetch the full email message using the 'id' from the Pub/Sub notification.
Extract the 'subject' from the full email message.
Perform your filtering logic based on the 'subject'.
This approach would require additional processing and API calls, but it would allow you to filter emails based on the subject or any other part of the email that isn't included as an attribute in the Pub/Sub notifications.