Gmail API Watch Request Not Filtering Label IDs - gmail

Issue
Trying to get the Gmail API to send only new messages to Cloud Pub/Sub by using the Gmail APIs Watch function but when setting the labelIds in order to filter to just INBOX, i am still notified of all changes, files sent, drafts etc.
I've looked online and can see that there are people that are experiencing this issue and there is even a bug out for it https://issuetracker.google.com/issues/36759803.
But i find it kind of odd that the entire feature of filtering just doesn't work and its been an issue for 5 years according to the bug report. Makes me think its just me that is doing something wrong. Would be cool to hear from anyone that has got this to work.
Where im at
I'm using the Gmail API, trying to get my Gmail account to publish messages to Cloud Pub/Sub. I've managed to do this however im trying to filter what i get notifications for to just new messages. This is where i have a problem.
According to this Gmail API documentation, it appears all i have to call is the code below and that should be that. I will add however, that im calling the Kotlin equivalent, but i don't think this should matter.
request = {
'labelIds': ['INBOX'],
'topicName': 'projects/myproject/topics/mytopic'
}
gmail.users().watch(userId='me', body=request).execute()
What im calling:
val request = WatchRequest().apply {
labelIds = listOf("INBOX")
topicName = "projects/myproject/topics/mytopic"
}
gmail.users().watch("me", request).execute()
Other things ive tried
I have tried adding labelFilterAction = Include and other variations but they all seem to be ignored.

After trying the ideas listed by ziganotschka, I'm more confident that the issue is not related to specific client libraries.
I managed to speak to someone at Google who in turn contacted the G-mail API team. They said they were aware that this is an issue, that it has been an issue since 2015 and was most likely caused by a change they made back then.
A ticket is still open, but doesn't look like it will be fixed.

Perform the following trouble-shooting actions
Provide a request body including labelIds, labelFilterAction AND topicName as specified here
Try the label "UNREAD" instead of "INBOX"
To discart Kotlin implementation related issues, test your request in a programming language that allows you to pass the request as a JSON body in exactly the same way as specified in the documentation.

Related

Is there a way to achieve the same behavior of sending notifications as email notifications using GitHub API?

I'm building a Telegram bot for myself that should send to me notifications when I get any. I'm trying to achieve the same behavior as GitHub's email notifications. The problem is that I'm not sure if it's even possible. I'm working with GitHub API for few days straight trying to solve this issue but I still have no idea how to do it. It's like GitHub API doesn't provide enough information about the notification.
For example, it provides field "reason", which describes why I got this notification but how to understand what this notification is about? Like, if I was assigned to the issue or pull request (right now it seems like notifications are the same whether I got assigned to the issue or got a new message in the assigned issue), or got a new message in a watching issue/pull request or anything else.

Weird Issue With Instagram API

Issue:
First API calls only returns top 3 posts.
The next_url returns no data(data array is empty and pagination string is null)
The 4th post is suspect because I am unable to get it with API calls and it is not returned in the first API call.
Details:
Using v1/users/self/media/recent endpoint
Using Javascript to loop through calls, using "next_url" for the 2nd and subsequent call.
Using Access Token
Worked fine(returned all posts) until "the 4th post" was made
Why do I think one specific post is the issue? Because I am unable to retrieve it using the API. If I set the max_id to this post id, then I get all other posts before this post.
If I leave max_id out, the first call gets all posts newer than this post.
Verified that I am not in a Sandbox.
Has anyone encountered this before? and why would one post be breaking the next_url API call? Is there something in the post causing this?
I can't give out the IG account, sorry I know that would help, but it needs to remain private.
I am a developer on a project that makes extensive use of the legacy Instagram API. It has, for a long while now, been extremely flakey. We have experienced your exact issue many times and there is no practical solution.
However, all Instagram APIs have now (finally!) been migrated to Facebook. You should use the new Instagram Basic Display API which will be properly supported going forward.

Control your device with custom commands using Actions in Google

just getting started with Assistant features in RPi and I am able to successfully implement upto this point and wondering few thing.
Scenario:
user: hey google "please turn on my living room Lights"
List item my code in horword.py : has a function to perform same action based on ON_RECOGNIZING_SPEACH_FINISHED
RPi/google home: I am not sure how respond to that
I was able to capture the request query asked by user using ON_RECOGNIZING_SPEACH_FINISHED = Args.text(str) and use it in my logic to perform the task. However, at the same time, "ok google" is responding with this answer.
to mitigate this problem, I created an google-actions, now it understands my query and respond with intention from api.ai. However, didn't acts on turn lights ON. So, wondering how can I read response from google home/api.ai in text and change code to act on it locally.
appreciate it.
You will not get response as text.
For getting response to client app use webhook in API.AI and send message using fcm to client app.
Read the fcm message in client app and do the corresponding actions.
finally was able to figure out multiple ways. answered this in other stack question. find more details in this post.
Multiple ways to handle this since google doesn't gives voices transcript and we let google say our transcript which is kind off solution for now.

how subscribing to instagram realtime api helps me to get user/media details

I have subscribed to instagram realtime api to receive POST updates for hashtag #sudhir
I am able to get updates to my server this way :
{"changed_aspect":"media", "subscription_id":2935881, "object":"tag", "object_id":"sudhir", "time":1362748903}
I don't find any user related or media related info in these updates. I found in SO that we have to hit their (instagram) endpoints explicitly to get photos/user info, inspite of subscribing to endpoints.
If we have to make request explicitly, then what is the use of subscribing to particular endpoint.?
What is the use of this json data ({"changed_aspect":"media","subscription_id":2935881,"object":"tag","object_id":"nofilter","time":1362748903}) we get in request body of our servlet. ?
Can we use this data in any way to get actual data of user/media ?
Any help or suggestions would be appreciated :)
Nothing useful I'm afraid. Once you have that information you know that something has changed on Instagram's end. You are then supposed to fire off the corresponding request. From your example it looks like you want to then do a tag/recent/ request and filter out anything earlier than the "time" variable.
Not the easiest way to do things unfortunately but they seem to have decided that the hard way of doing things is the way to go.

User authorization in google talk with nodejs and node-xmpp

I'm writing a bot in node.js using node-xmpp. So far it's pretty straight forward except I'm having an issue with figuring out how google Talk handles it's user authorization (when dealing with requesting to chat with someone NOT on your roster).
I'm catching all stanzas coming through and logging them to the console but there is no data coming from the user that is requesting authorization.
Any explanations of what I should be looking for or if this event even happens over the jabber protocol.
[appended] I know that technically when a subscription request is made a presence stanza is sent with the subscription request. I can't see these coming over the wire using node-xmpp for some reason. Also, I need to find out a way to determine what presence requests are "pending" when my bot logs in. I thought (innacurrately) that they would be listed in the roster with some sort of flag, but that's not correct.
Any help with finding out where to go from here would be useful.
Ok, I finally figured out how to get the subscription requests after they have been made. There isn't much info on it out there so I'll put together a blog post, but I feel that answering it here might be good as well.
I found that if I did a google roster query based on the below information:
http://code.google.com/apis/talk/jep_extensions/roster_attributes.html
example stanza:
<iq from="username#gmail.com/D2D4E5A8" type="get" id="google-roster-1"><query xmlns="jabber:iq:roster" xmlns:gr="google:roster" gr:ext="2"/></iq>
The server would respond first with your pending server subscription "presence" stanzas
ex:
<presence type="subscribe" from="pendinguser#gmail.com" to="namehere#gmail.com/D2D4E5A8" xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client"/>
and then the rest of your roster's "presence" stanzas. It's important to note that your subscription "presence" stanzas don't get sent to you from the server unless you do a roster query. I'm not sure why this is and why it's not documented somewhere is beyond me. Anyways, at least I can get the list of people trying to get access to my bot now.
Note: This is not my area of knowledge just an interest of mine. I have not got practical experience just a bit of research. This would have been a comment however doing some more searching on the topic, I have come up with some more things that might help.
Here's a google chat chat room homepage http://partychapp.appspot.com/ you can get the source http://code.google.com/p/partychapp/
Those links came from http://xmpp.org/2010/02/xmpp-roundup-13-services/ which has quite a few other resources that might be helpful.
http://code.google.com/p/node-xmpp-bosh/ has some code about that, I've not done it but the topic is interesting.
I hope if you do find the answer your after you write up a blog post and or a project and share it. It would be of interest to me.

Resources