Hangouts/Chat - messagesUnread always 0 despite new messages - hangouts-chat

I'm trying to write a Hangouts/Chat dockapp to show unread message notifications, I'm using the following scope url:
https://www.googleapis.com/gmail/v1/users/me/labels/CHAT?access_token=<my_access_token>
The json returns fine, however messagesUnread is always 0. I've disconnected every possible app/browser etc that could be grabbing the messages before I reloaded the above URL, sent a new chat message from another account and messagesTotal increments by 1 but still the unread stays at 0. Even if I disable hangouts in the gmail web interface settings, send a message and search by "label:chat" the chat message that was received arrives marked as read in the web interface. If I manually mark a chat message as unread then the values in the above url do change correctly.
I can obviously work around this by storing he previous messagesTotal on comparing to current, however that creates a requirement to click the app to acknowledge the unreads which is a tad annoying.
Has anyone found a way to get a true unread count from chats/hangouts?
Thanks,
Haydn.

If you use the method users.labels.get for any other label (e.g. INBOX), it will return messagesUnread correctly.
Unfortunately for the label CHAT this is not the case
Chat messages are not quite the same as emails
It is not clear either it is intended behavior that you cannot retrieve the unread chat messages or a bug
This issue has been already filed on Google's Public Issue Tracker, but it has been closed by Google because it has been reported in Spanish.
Feel free to report the issue in English to hopefully obtain a response from Google eihter the bheavior is intended or a bug.

Related

Mailjet: Exlude an email from being tracked when open-tracking is enabled

I am using Mailjet to send emails and have the 'open tracking' enabled ("Once activated, an invisible tracking pixel (image) is added to each email you send via Mailjet").
What I want to do is to deactivate the inclusion of this tracking pixel for certain emails. I know that it is possible with Mailjet for links to do that, but were not able to find a similar functionality for the tracking pixel.
Thank you!
Yes you can. (perhaps not at the time of the original question)
API send request accepts the Mj-trackopen field.
SMTP way accepts the header X-Mailjet-TrackOpen
API info - https://dev.mailjet.com/email/reference/send-emails/
SMTP info - https://dev.mailjet.com/smtp-relay/custom-headers/

How can I search for messages (embeds) with a particular 'author' through DiscordSocketClient?

I'm in the process of building a new Discord bot (of course), and I've been working on the Twitter integration using Tweetinvi. I've got most of the Twitter streaming bits working normally (at least, as far as I can tell in my simplified testing), but I wanted to have the bot modify/delete posts in Discord if the Tweet is subsequently deleted. Tweetinvi has a TweetDeleted event that I can use to detect this as a part of my stream, but I'm having difficulty figuring out how to find the post in Discord.
What I'd like to do is "simply":
Search for posts (embeds) from the author (defined by the original Tweet)
Find the post with a matching .Url value in the embed
Replace that post with a message like "THIS TWEET WAS DELETED".
The problem I'm running into, however, is I can't seem to find a way to do "step 1" - search for and return any posts from the specified author. The only option I've found so far is the GetMessagesAsync method, but that doesn't seem to have a way to filter the results. Plus, with the "soft limit" of 100 messages, I worry that I could still not find the message I'm looking to delete.
I post the embeds using the DiscordSocketClient object in my class like this:
Me.A1FDiscordClient.GetGuild(Server.ID).GetTextChannel(PostingChannel).SendMessageAsync(MessageText.Trim, False, TweetBuilder.Build)
I had started working on something similar for the deletion/modification, but I think I'm simply spinning my wheels at this point:
Dim Messages = Me.A1FDiscordClient.GetGuild(Server.ID).GetTextChannel(PostingChannel).GetMessagesAsync(100)
I'm probably being dense and/or completely overlooking something, but I'm not even sure what to do with this once I have it. I was looking at using the .Select(Of TResult), but I think I've just gotten myself too twisted. I don't necessarily need a whole solution, but I could really use someone giving me a nudge in the right direction.
Discord does not provide an endpoints for Bots to search/filter on specific criteria. The only way to retrieve messages is to use the GetMessagesAsync() method
The limit for GetMessagesAsync() is technically Int32.MaxValue. The 100 that you see is simply the default. This is because Discord will return in chunks; 100 messages at a time. For example if you set the limit to 1000, you will get 10 chunks of 100.
Possible issues with retrieving a large number of messages? The main issue would be the length of time taken to retrieve the messages, which could block the gateway unless offload the process to its own task.
A possible solution would be to implement your own system for linking and storing twitter posts to discord posts. Could be as simple as a dictionary of Twitter post id and discord post id which would allow you to easily find the message id related to a given twitter post.

Send an initial message when people first invite the Telegram bot

I am using Python and have previously built Telegram chatbot before.
However, now I want to create a chatbot such that when someone invites it, it will send an initial message that says something like "type /start for instructions".
This is to make sure that they know what to do when they first invite the bot. Can this be possibly done?
I am trying to use bot.send_message(chat_id=chat_id, text="type /start for instructions") but the problem is I don't know how I could obtain the chat_id.
Unfortunately, you cannot do it :(
Here has another way you might interested: /setdescription in #BotFather.
It will be shown in the What can this bot do? section as the picture below.
After digging this issue - here's what I've found:
The reason:
Intuitively it seems logical to allow a feature that sends a message to a user (as a reaction to the user's action for starting the chat). BUT, because telegram APIs are truly vast there is a fair chance for abuse in this format (a message with button that drives the user for action without the user truly understand the consequences). From here my question changed from "how to implement this mechanism?" to "Which alternative do I have?"
There is an alternative!
My initial goal was to make the "what can I do here" factor as clear and effortless to the user as possible. Technically speaking - all methods that can be invoked without the chat_id can be invoked as part of your bot setup process and will affect all users. One option is to create a list of commands to your bot. This list will appear when the user use the / operator and it's a common practice among chat users. For my intention - I needed something even simpler than that and I think that the setChatMenuButton is very suitable. This method allows you to create a web app and allows the user to simply click it instead of typing text. When clicking the button it triggers a dialog that clarifies to the user what's going on and from there - it's basically your imagination that will define how the end-user will experience your process. I managed to execute this call using a wrapper that I've build (which handles the base url as well as secret key) using this code:
await api.get('setChatMenuButton', {
menu_button: JSON.stringify({
type: 'web_app',
text: 'Name of your app here',
web_app: { url: 'https://your-domain.com/ppp/path/goes/here' }
}),
})
More about Telegram Web Apps
And a little screenshot from my experience:

Receiving notifications

I run a parse app that is basically an appointment system but I was wondering if there is a way that my app/parse can notify me when someone sets an appointment? As of right now I receive no emails or any kind of alert so I have to stay on the parse site, and refresh it every 5 minutes.
One thing you could do is write a cloud code pre save function that sends you an email automatically every time an appointment is saved.
https://parse.com/docs/cloud_code_guide#functions-onsave
That link should help you get started on writing a cloud code function on save for your objects.
As far as sending an email from Javascript, I believe it is doable, here is an example of part of a response that could help you:
http://stackoverflow.com/questions/7381150/how-to-send-an-email-from-javascript

Auto email response from Shopify api

I've successfully created a script that will import username/passwords etc into Shopify (using the api).
However, when I do this an automatic email is sent to the customer. I don't need this and can't find a way of either modifying it or turning it off. There is no mention of the email in the api documentation which has meant me finding out the hard way (by some clients complaining!)
The email is not the same one that is sent to the customer when a new account is set up. So where does it come from? How can I switch it off/modify it's contents?
Any ideas?
Well, after some digging I found where the email message was being generated from. It is one of the default messages that are already set up in Shopify (Customer Account confirmation) under 'Emails & Notifications'.
Just make sure you change this before you start running your shop as the default message is a little 'dry'.
Thanks for your help guys.