Facebook real time inbox messages with Graph API v2 - facebook

Does anyone know a way to fetch a user/page inbox messages in real time?
I've found this link, but there is no mention about inbox messages.

The Real-time updates are about... -updates-. That means you will only get notified about changes in the fields described in that link (not regarding the Payments API, that's a different case).
So, you can't get real-time inbox messages.
You can subscribe to the notifications, but I'm not really sure if Messages notifications are included in those...

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

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.

Facebook Messenger Send Api - send to a big amount of users

I have a bot over Facebook which people are subscribing for sports updates.
I have 1,000 - 10,000 users I want to send out an update to.
Currently, in small scales like 20 messages , I would use a Facebook Batch request.
But, i'm not sure what would be the best way to send my messages in a large scale.
My two options are:
Batch - limited to 50 requests per batch request.
I don't really know if I should expect a delay in the execution of the request.
Regular calls - I will iterate through my receivers and send each of them a message separately.
I'm afraid Facebook might block me for thinking i'm spamming, or I will exceed the rate limits.
I have to say I was expecting a more generic method coming from Facebook since they are allowing users to subscribe for update through my bot, hence, I was expecting them to provide a guide on what are the best practices for sending the update users subscribed for.
You should definitely use Facebook Messenger Broadcast API for this. This will broadcast your message to all user subscribed to the bot.
Caveats:
You have to apply for this permission. (pages_messaging and pages_messaging_subscriptions.Takes about 1-2 days, but
can test on Admin/Test users of the app)
Each broadcast has to be a separate broadcast. (e.g. you can't send image and a text together, each has to be its own individual broadcast).
Have some kind of un-subscription option as well. FB user might think you are spamming even if you clearly say in the messages that your bot will send updates.
Use custom labels to create targetted sends. So you can either subdivide who you will send updates to about specific issues or just label people if they unsubscribe to your broadcast or not.
Basic workflow:
Get permission to broadcast.
Create message_creative_id via POST to endpoint
Use message_creative_id to POST a broadcast_messages
On a successful send you will get back broadcast_id

FbChatBot mark message as Read

i am developing fb chat bot, and i want to mark the message as read so that when the moderator of our fb page view the message part, they won't see so many unread messages even though the fb chat bot has already replied that user and they don't need to click that message just to mark it as "read".
How can i achieve this? I am trying to use this API: but it doesn't work.
https://developers.facebook.com/docs/messenger-platform/send-api-reference/sender-actions
You can not mark message as read (as of now), but the best way I deal with this is to use Handover Protocol
When your bot reply the message, it won't appear in INBOX, but it goes to DONE box instead.
When bot cannot answer, you can let your bot pass thread to INBOX. Then the moderator of page manually answer it. (and mark as DONE afterward)
Follow the instruction here to set it up:
https://developers.facebook.com/docs/messenger-platform/handover-protocol/pass-thread-control
(Note: You can pass thread to page inbox and then take thread back immediately. I will notify to INBOX, but your bot can still work with users.)
When you use the API you sent here (Facebook's Send API), you only mark the message as "seen" from the bot on the Messenger Chat that you have with your users. This doesn't affect the messages inside your Page's inbox.
Unfortunately, there is no way to mark messages as read inside your Page's inbox.
Is this new feature of fb bot? Thanks btw! I will try to check this.
Is there any side effects in Marking the message as done ???
To answer your question:
There are some bugs within the Inbox/Pages Manager mobile app. You won't see the messages in DONE folder if your admins are using Pages Manager mobile app for now.
I've reported the issue and working with them to solve it. However, you can still see those messages in DONE folder if you use a computer and go into your page's Inbox.
NOTE: It seems that messages moved to Inbox will be marked as seen (not bolded). This may be a little confusing if your admins don't mark each conversation as DONE after admin finishes conversation with the users.

Facebook Graph API subscription to /pages/conversations does not update on outgoing messages

I'm working with Facebook pages and building an app that allows you to send/receive private messages for your page from an external app.
Everything works fine, I can import old messages, send new one. My issue comes from the real time update subscription.
As explained here and here, I have subscribed to the conversations field on the page object. I also set up my server to receive Facebook verification and the updates.
I do receive updates when someone sends a new message to my test page ( even if it's a bit slow ~30 sec delay ) but I never receive any updates when the page replies to a message.
Is there something else I need to subscribe to in order to receive these updates ? Do I need to look for another way to do it ? Or is it just not supported by Facebook real time API updates ?
Any help appreciated, let me know if you need more info and have a nice day.