GAE channel API chat - channel-api

Currently im trouble shooting some code that I wrote to create a chat room. I will include the code if necessary but for now I just wanted to hear some possibilities for the problem im having. So basically I have client1 that is listening to a channel and then when clien2 sends a message to the server the message is then sent from the server to all available users. What is happening is that client 2 will send the message and it will be displayed on his browser but client 1 will not receive the message until he refreshes the page or types in a message of his own. So I would think that user presence is being detected fine since the message eventually gets sent to all available users but im not sure? Thoughts?

The Google App Engine blog has a nice case study that talks about how to do this.
They store a list of channel ID's in memcache and send update messages to each of them. They mention that race conditions make memcache not ideal, but it worked well enough for their demo.

Related

Can't get Google Chat messages with Gmail API

What are the details of your problem?
Until recently, in my own web application, I used the Gmail API to retrieve Google Chat messages as follows.
I was able to get it from "Label: CHAT" by executing as follows.
(1) Acquisition of thread ID belonging to CHAT label
https://gmail.googleapis.com/gmail/v1/users/me/messages?labelIds=CHAT
(2) Get message information from thread ID
https://gmail.googleapis.com/gmail/v1/users/me/threads/[Thread ID]
However, it seems that it has been impossible to obtain it since around December 2022, and when I searched for "in: chats" in Gmail, the messages after December 10th were not displayed.
Any method is fine, so I would like to be able to get Google Chat messages as before.
Anyone know the cause and solution?
Please check.
I also tried using the Google Chat API to see if it was possible to get messages, but I could only get messages in the space, and I couldn't get direct messages, so I wasn't able to use it.
I checked all the messages in the labels that can be obtained at "https://gmail.googleapis.com/gmail/v1/users/me/labels", but it seems that chat messages are not included.
Also, in another answer, there was a description that the state included in the Gmail API was a bug, so it is possible that this bug was adapted and it was not displayed, but in that case, there is another way to deal with it. Are you there?
Access CHATS label with Gmail API

Hangouts Chat bot to post timed message

I can see from this, that a bot can send a message in chat, and if supplied a thread ID that does not exist, will start a new thread and post there. I am wondering if there is a way, given the current REST API or any other compatible with Hangouts, to send a message to a room at a given time of day, rather than when the bot is called or interacted with.
I am working in NodeJS, deploying my project in the GCP.
My apologies for the ambiguity of my question, I am trying to wrap my mind around the GCP environment.
In the bots documentation there are described the three ways in which a bot can send a message to a room. Those are:
Every time the bot is mentioned.
When the bot enters a room for the first time.
When the bot is taken out of the room.
Unfortunately, none of them is a daily message at a given time. If you still have questions, please ask them freely.
We have a working bot (NodeJS based) which sends messages freely. Just use this endpoint https://developers.google.com/hangouts/chat/reference/rest/v1/spaces.messages/create .
Your bot must be invited to the particular space/room for this. You can create threads as well with new and subsequent messages.
We also have bots written in Google Apps Script and there it is also possible.

How to set up an e-commerce messaging solution using ably.io

I have an e-commerce website and I want to implement a messaging solution between my clients, using ably.io. I am new to ably.io and also to pub/sub message pattern and need some advice to put me on the right track.
Let’s say I have 75,000 users on my website. Users can create an advertisement... if anyone is interested in the advertisement they should be able to message the advertiser.
This is the solution that comes to my mind after reading ably's documentation:
Since I have 75,000 users, I create 75,000 channels, 1 channel per user.
An user named Brian creates an advertisement on the website. Brian subscribes to BrianChannel to receive all messages on his own channel. Now Amy and Tom have seen Brian's advertisement and want to contact him, they publish a message on BrianChannel and Brian would receive the messages.
I am not sure if the above solution is the right approach?
If the above solution is the right way, I have 2 further questions:
Let's Brian uses JavaScript to subscribe to BrianChannel. Now Brian is obviously not online 24/7 - how should I handle his messages while he is offline?
I have 75,000 users registered on my website. At any point of time 5,000 users are online. Out of these 5000 users online, 20 users are actually messaging each other. Using my solution above, I should have 5,000 active channels for all the online users... Is there a way to reduce the number of active channels? Perhaps by periodically polling the channels?
This is Srushtika, Dev Advocate at Ably.
Your approach is correct and is in-fact the most commonly implemented one. i.e, each of your 75,000 users will have their own channels to which only they will be subscribed to. Any other client who wishes to send them a message, will attach to 'their' channel and publish messages to it. Since all users are always subscribed to their own channels, they will be able to receive any messages intended for them.
If any of your subscriber clients are not online at the time a message is to be sent to them, Ably's Realtime platform will, by default, retain it for 2min after which, if the subscriber client is still offline, the messages will be discarded. However, using the Persisted History feature, you can increase the time for which messages are retained to 24-72hrs.
Unfortunately, as of now, Ably doesn't offer a mechanism to detach from channels with no activity while the client is still online. But, this feature is coming soon. Keep an eye on our Engineering blog where we post all such updates.
Hope that answers your question.

Random duplicated messages in messenger bot

all.
On the last week we are facing a problem in messages order, in Facebook Messenger.
When user is interacting with our bot, on most of the cases Messenger send random messages that it has sent before in the conversation. This old messages are not triggered by our bot, they simply appear, which makes us to think it is a Messenger thing. After a while, when user leave the conversation for some seconds and get back to it later, the bot is ok again. Sometimes user has to say "hi" to bot, so it gets back to the right point of conversation.
It also happens with messages that were sent by user, not only by our bot.
We have never get this problem using it on web platform. It seems to occur only in Android devices (Android massenger app), until this point.
When we check the conversation from the fan page side, it is all ok, and it is hard to determine where the problem occured just by looking from the fan page perspective. It seems there is no problem. But if you are the one who is interacting with the bot is very bad, it is like a "crazy" conversation for the end user.
It is a different case from the listed on other topics. We have an information thread that sends lots of messages, and in this case for example, it has never failed in order. It just happens when there is an user-bot interaction.
Is anybody here facing this kind of problem with messages order?
Thank you in advance.
we have seen the same behavior in android
On further investigation, we found that the messages which we assumed are delivered to the users were actually not delivered.
What we did was started listening to delivery notification and read receipts documentation link. We saved every message at our end and then mapped with seq number and it turns out that there is connectivity issues in android for fb messenger (reference).
When fb messenger is running in background and there is poor network connection then messages are not being received. This is what I have observed when I have poor network connection.

Getting first thread id for Facebook XMPP using Asmack

I am using asmack on Android to talk to Facebook XMPP.
When an incoming message arrives, I get the (XMPP) thread ID from that message/chat. Sending further messages (using that ID) works just fine.
The problem starts when the first message is sent from my application's side. Then I don't have the current thread ID (since they change on the Facebook server). And sending the message does not work. My system sends OK, but it is never registered on Facebook.
So, how do I get the initial (XMPP) thread ID from an inbox chat?
I tried using the graph API to send a message (inbox/comment). But it does not work (you have to be whitelisted... whatever it is).
Please help, how can I initiate an XMPP thread, and not just respond?
Study the one of open source project which used Asmack then you will be get clear idea how its working. Beem-Project is one one of open course project which used Asmack
It turns out that Facebook will accept any thread ID you give it. There was a problem in the way I handled new message threads created locally, rather then external created threads (from Facebook). Now everything works, even firing up a thread from my application, using asmack.