I want to receive webhook requests when I get new emails, but it does not work. Here are the steps (Push Notifications)
I have already done:
The problem is that when I send an email to my mailbox, Gmail does not trigger Pub/Sub to send a webhook to my server.
Here is my server watch code (this code works fine for manual push but does not receive any requests when the email inbox changes):
async setWatch() {
try {
const topicName = "projects/projectName/topics/topicName"
const gmail = google.gmail({ version: "v1", auth: this.oAuth2Client })
await gmail.users.watch({
userId: "me",
requestBody: {
topicName: topicName,
labelIds: ["INBOX"],
},
})
} catch (error) {
console.log(error)
return null
}
}
What am I forgetting or missing? please help. thanks.
I tried every setting I could think of that might relate to preventing the Gmail API from triggering Pub/Sub, and I finally found the solution. The problem was that my current project status was set to production mode. I switched it back to development mode and then switched it back to production mode again. The problem was solved.