GMail stops sending push notification - gmail-api

I've configured the push notifications following this guide and when calling the watch endpoint I get an expiration of about one week.
During this period I expect to receive notification to the Pub/Sub topic I've configured without the need to call the watch endpoint some time before the expiration date.
However what happens is that after about one day I'm not receiving notifications anymore and calling the watch endpoint doesn't help.
Why GMail has stopped to send notification to the subscription endpoint?

Gmail Pub/Sub notification subscriptions expire in 7 days, you have to call watch() again to renew your subscription.
https://developers.google.com/gmail/api/guides/push#renewing_mailbox_watch
Maybe that's the issue.

Related

Gmail API PubSub Push Endpoint is triggered twice

We have integrated Gmail API into our app to get the email inbox updates of Gmail accounts. We have used Gmail watch API to start listening to the updates of the Gmail inbox of a user. We have added a subscription and mentioned the endpoint of our app, Topic-Subscription details screenshot attached below, where we are ready to receive inbox updates.
But there are some Gmail accounts, whenever an email is received on those accounts then our "push endpoint" is triggered twice instead of once. That's causing a problem within our app.
Can you please explain that is it possible that a push endpoint can be triggered multiple times, on a single email received at the Gmail inbox?

Watch request successful but not receiving any messages

I am trying to get Gmail push notifications by setting up a watch notification. I went through all the steps in the Push Notification guide and received a successful historyId/expiration response, but since then all's quiet. I haven't gotten any of the emails pushed through. Any ideas?
AFAIK, your application will only receive a notification message describing the change if the mailbox update matches your watch request.
With this, try to provide the topic name and any other options in your watch() request, such as labels to filter on. For example, to be notified any time a change is made to the Inbox:
POST "https://www.googleapis.com/gmail/v1/users/me/watch"
Content-type: application/json
{
topicName: "projects/myproject/topics/mytopic",
labelIds: ["INBOX"],
}
Other than that, check your Gmail notifications settings. If that still doesn’t work, try the troubleshooting steps given here.

Shopify Webhook getting called multiple times

In my shopify store I have setup an order creation webhook. The webhook points to a Cakephp action URL which receives the data from webhook as following:-
$content = file_get_contents ( "php://input" );
After that it is saving this order data to the app database as:-
$orderData =array('order'=>$data['order_number'],'details'=>$content);
$orders = new Order ();
$orders->saveall($orderData);
Now the issue is that for each single order created the webhook is getting invoked multiple times. Although it performs the necessary action in the first attempt, yet Shopify is not able to identify the call success and is getting it invoked again and again until the limit reaches. After the limit is reached the webhook is getting deleted from the store.
My question is that do we need to send any type of status or response to the webhook call after it performs the necessary action. Because it is not very clear from shopify webhook documentation. They state that webhook call success is determined from HTTP status 200. How can I check what is the status returned by a webhook call? How can I make sure that Shopify is informed of webhook success through my app code and it does not invokes further calls to the webhook?
Yes, you need to send a 200 response to Shopify within a short time 5s. Otherwise, Shopify will send a request in a short time.
The official guide suggests that you store the webhook data and process it with a queue, thread, or whatever ways you preferred. After that, you return a 200 response to Shopify immediately.
IMO, if there are many webhook requests sending to you, it's better to separate the webhook receiver from your app server. You can do it with AWS Lambda or docker swarm so that the webhook requests won't break your app server.
Source:
Time limit: enter link description here
Webhooks with AWS Lambda: enter link description here
Just to clarify for others, you have to explicitly return a 2XX HTTP code or it'll retry 19 times over 48 hours, then delete your webhook if it exceeds that.

Stop notification for google watch when token is expired

Here is the situation.
User is connected to our application and we have authenticated him with google calendar to start Watch for any event on his calendar.
We have stared getting the event notification but now User access token is expired and we are not sure when user will re-authenticated him self with our app.
But we are still getting the notifications, which we want to stop, but we are unable to stop the Watch because his access token is expired.
Is there any way we can stop the Watch with above mention scenario?
Thanks in Advance
The notifications should stop automatically in expiration time. You can choose to stop receiving notifications for a particular channel before it expires by calling the stop method at the following URI:
https://www.googleapis.com/calendar/v3/channels/stop
This method requires that you provide at least the channel’s id and the resourceId properties, as shown in the example below.
POST https://www.googleapis.com/calendar/v3/channels/stop
Authorization: Bearer {auth_token_for_current_user}
Content-Type: application/json
{
"id": "4ba78bf0-6a47-11e2-bcfd-0800200c9a66",
"resourceId": "ret08u3rv24htgh289g"
}
Check this documentation on how to stop notifications.

Receive slack bot messages via requests to external URL

Is it possible to receive direct messages on behalf of a slack bot via POST requests to a certain domain?
I want to have an endpoint in Google App Engine that receives incoming direct messages from Slack via POST requests, and posts messages back via the API. Is it possible?
You can use the new Events API. Create a bot, subscribe to message.im events, and set your endpoint as the callback URL
You just need to set up an "outgoing webhook"in slack and point it to whatever endpoint you need on your GAE server. In order to respond just use an "incoming webhook" to receive the answer.

Resources