Google Calendar Watch and Events working together - events

I am creating a Node/Express Webapp that would mirror a user's calendar. It would get a notification for every change in the users calendar, and would update the DB with the latest of that user's calendar.
Lets assume that we want to monitor john.doe#gmail.com. Kindly tell me if this is the best (and only) way to do it:
Set up for Push notification - While doing so, we provide (amongst other fields):
token - A plain-text that would be echoed back. This is where I can put something like 'calOwner=john.doe#gmail.com'
id - A UUID channel id
Upon every change, my webhook will get a push notification that would contain:
token : calOwner=john.doe#gmail.com
id : the channelId - I dont understand if this field alone can be used to trace this notification message back to john.doe#gmail.com
Now that I know john.doe#gmail.com has changed, I would do a list with a synchToken. This will return me the change in john's calendar since last synch
What baffles me here is that the seemingly important fields channelId and resourceId (which appears as x-goog-resource-id in the push notification header) are useless, and the only field that ties the push message to list is an optional plain-text field token .
Kindly tell me if this is the only way to track a user's calendar.
UPDATE
Thanks #KENdi for the answer.
My struggle was with the point that simply looking at a push notification message, there is no way to trace it back to john.doe#gmail.com . I now understand why such is the case, that a push notification does not contain the calendarId, but the resourceId instead (which, in plain terms is the event object). It is so because an event can be associated with multiple calendars, and hence multiple calendarIds. Hence, it is the subscriber's responsibility to maintain association of the channel to the calendarId that he had used to create the channel at the first place.

Yes, you are correct, you need the calendar push notification, to notify you about all the changes happened in the Google Calendar.
The purpose of X-Goog-Resource-ID is an opaque value that identifies the watched resource. And this ID is stable across API versions.
Check this SO question to know more about the purpose of X-Goog-Resource-Id.

Related

Slack `member_joined_channel` - how to check if my bot was invited?

I want to send a message to any public channel that my bot gets added to. I notice there's the member_joined_channel event as documentated here, however I'm not sure how to figure out when to determine if my bot was the invited member. I know there's the user property, but I don't want to hardcode my bot's user ID.
I'm not familiar with the slack API, but i found this endpoint :
https://api.slack.com/types/conversation
In the response, you have a flag is_member which contains what you need I think :
is_member indicates whether the user, bot user or Slack app associated
with the token making the API call is itself a member of the
conversation.
EDIT:
then, you can retreive the list of public channel and have this flag on every channel accessible :
https://api.slack.com/methods/conversations.list
If you are writing a WebSocket-based "RTM" bot, you can listen for the channel_joined event, which is sent only for your own user/bot.
For the more typical Webhook-based bot, the best choice is to listen for the member_joined_channel event and compare the user field if you want an event-based implementation. Hardcoding or otherwise storing your bot's user id is a necessity.
Otherwise, as suggested in the previous answer, you can periodically query all conversations with the conversations.list method and check if you have become a member using the is_member field.
In case one of these methods does not provide the is_private field that you need to determine whether a channel is public, you can use the conversations.info method, which returns a channel object with the is_private field.
Coversation info is your friend https://api.slack.com/methods/conversations.info

How to find message's file unique IDs with Telegram bot API?

i'm experimenting with Golang Telegram bot APIs and I have a problem with the ID of the message's file that i send to the bot.
I forwarded a message of type VOICE to the bot and in the code I read the unique ID of this file to understand if the bot received that voice message yet (... maybe forwarded by another user).
The problem is that when I read the ID with this code msg.Voice.FileID I get always a different string. But not completely different, the first and last part of the string is always the same, but the middle part changes, like this:
id first time i forward the message: aaaaaa_abc_zzzzz
id second time i forward the message: aaaaaa_def_zzzzz
The doc does not say anything about it... (https://godoc.org/github.com/go-telegram-bot-api/telegram-bot-api)
Do you guys know how to deal with file ids? My goal is to be able to say "ok, I received this photo (or voice, or audio, or video) yet from this or another user"
Thank you for your time
Ve
As a reddit user pointed out here, it is possibile to have the unique id of a file as per v4.5 of the Telegram API https://core.telegram.org/bots/api-changelog#december-31-2019.
I couldn'd find that out because a was reading the Golang implementation godoc and the "unique id" feature is not yet implemented.
I'm going to add it and make a PR.

Mailchimp - How to record data to subscribers list from 2 different forms

Ho everyone, I'm in trouble with my campaign, this happened to me... when i go to my list to see the data of the recipients.
It is asking me to create a reconfirmation Campaign, due to a too high volume of unsubscribed to this campaign.
Here the path I've been following to realise my campaign ( It is the first time I'm using Mailchimp):
I have an invitation to a event where guest can approve or decline the invitation.
When they Accept the invitation: it bring to the update profile form - which icahnge in the advence editor. This way We can record some data such as dietary requirements,etc which would be recorder to our subscriber list ons submit.
When people decline the invitation, we have link to the unsubscribe form. This way we are able to know Which person has decline the invitation.
From what I understand, this is way It stopped our campaign.
What I'm looking to achieve . . . and din't manage i slept 2 hours last night trying to make this work . .. and i m in a big rush :
How can I achieve to collect data with the path explain previously, without having this issue in the future - so without using the unsubscribe from - but two different forms ?
How can I access to the List of User who have accept the invitation, so I mean the Subscriber List. because since that happen, I can't access it - and obviously i don't want to send another email to the guests asking them to fill up again.
I really appreciate all the help that anybody can provide me with that,
Thank you guys !
If I'm understanding you correctly, you're trying to use list subscriptions to stand-in for RSVPs? That is likely to look really bad -- ESPs see high volumes of unsubscribes as suspiciously spammy -- you'd be better off using Interests or Merge Fields on your list to denote the user's RSVP rather than asking them to unsubscribe. As for your current account, follow the instructions in the email you received if you want to get your list back up and running again.

Efficient way of syncing Gmail Inbox messages using the new Gmail API?

A web application sends an email on behalf of a UserA to UserB, using the new Gmail API (Users.messages: send).
The synchronous response contains threadId, messageId which are stored in the database.
We then query the history API for any changes in user's inbox (Users.history: list).
Is there an efficient way to get all the updates since last sync (new replies, read/unread changes)?
One implementation that we tried was to filter the history API results through a custom label. Unfortunately, we noticed that once a thread/message is tagged with a specific label any subsequent responses are not labeled automatically and new replies are not included in the history API response.
A second approach was to query threads using gmail advanced search for a particular label and date (e.g. after:2014/08/29 label:MY_LABEL). The problem was that gmail does not return threads that were created before 2014/08/29 but had a reply on that date.
Any scalable suggestions would be greatly appreciated.
Not sure I understand here, users.history.list was made exactly for this. Given a previous historyId, you can then call history.list(previousHistoryid), iterate through the results to find all the message Ids that have been updated since the previous historyId. Then call messages.get() on all of those--for any messages you already knew about you can just call format=MINIMAL (to see label updates), and for new messages you can use a different format to get the message content if you need it.

Complex push notification query

I've been playing with Parse for a while and It's pretty neat! Sadly I just encountered an issue that I can't seem to get resolved.
As soon as an object ("Alert") is saved to my database I would like to send a push notification. The object saved contains a field called neighbourhoodName which is a string. I would like to send everyone a push notification subscribed to this neighberhoudName. (This ain't the problem, hold on! :-P).
My Alert object also holds a GeoPoint and I would like to send every user in a specific radius a push notification. As you might figure a user could be subscribed to a neighbourhood (for example 'Hellas') and also be currently in the neighbourhood of 'Hellas'. This means he/she will receive two notifications.. this is not what I want.
So I thought; lets use Parse.Query.or. Send a push notification if the user is subscribed to the correct channel OR is in the current radius of the Alert. Sadly, Parse.Query.or can't be used with GeoPoints.
How can I tackle this problem?
Thanks a lot!
I found there to be some issues when using [query whereKey:nearGeoPoint:withinMiles:]. Using [query withinGeobox:] is much more flexible.

Resources