Pusher JS , displaying same message in two different tabs - pusher-js

Problem is when I do request to php server , is returning me messages in real time , so when I open page in second tab , and send request from first page , Is displaying same message on the second tab , but i did not request in second tab , or even.
Question does not Pusher use socket_id to display messages ? so why i can see message on the second tab if i did not send request on the second opened tab . any help ?

Pusher broadcasts messages to all clients subscribed to the channel. If you have two clients that should receive different events then they should subscribe to different channels.

Related

Agora web client SDK not returning a history messages as expected

I have created 2 users and done some chat between these users, but when click on specific thread the messages isn't appearing in proper format it's showing all send and received in a same column.

Unable to get timestamp of the message posted by Slack App

Whenever my app posts ephemeral message to Slack channel (in response to a query by a user), I am unable to get the timestamp of my Slack app response. As I want to delete it once the user has made a selection using one of the buttons. Although I have subscribed to 'message.channels' event, I don't get a notification to my app whenever my app posts in the channel (in response to the user input), therefore, I am unable to get the timestamp of the message which I'll use to delete it. All I want is the timestamp of the message posted by my app so that I can delete it but I am unable to receive the timestamp. Please help!
For e.g. in Giphy app for Slack. Let's say the user invokes the app by calling '/giphy [dog]' where 'dog' is just an example of a search term. The app responds by sending a gif and user can either send it, shuffle to the next one or cancel it. I want a similar capability of cancelling the app response but I need the timestamp of the message in order to do so therefore I am asking for help.
Thanks.
Your approach can not work, because Slack is handling ephemeral messages differently from "normal" messages. They are only visible by one user and can not be modified by API methods (e.g. deletion).
But of course its possible to replace ephemeral messages. Here is how:
Your app can just reply to the interactive message request from Slack with a new message. That new message will by default override the original message including ephemeral messages.
You can reply in two ways:
Directly reply to the request from Slack with a message within 3 seconds
Send a message to the response_url from the Slack request within 30 minutes.
See here for the official documentation on how to respond to interactive messages.
This approach works both with interactive messages and slash commands.
See also this answer for a similar situation.

How to send bulk im messages to slack users in my workspace? [duplicate]

I need to post multiple bot replies (responses determined dynamically) to the same channel.
The obvious way seems to be to do an HTTP POST for each message in succession using this API method: https://api.slack.com/methods/chat.postMessage
Is there a way to send messages to Slack in bulk to post to the same channel? The order in which the messages get rendered need not be important for me.
No, there is no bulk variant. So you basically need to build your own bulk message sender.
Keep in mind that there is a request limit of 1 message per second or your API requests will fail.
There also is a 3 seconds request time-out for many requests between Slack and your app. (e.g. for direct response to slash commands). So if your bot needs to send many messages you want to use an approach that allows you to send them asynchronously.
One solution to this problem that works very well for me is to use a messaging queue for all Slack messages sent from my bots.
You can try multiple messages as attachements -> https://api.slack.com/reference/messaging/attachments

Slack polls with HTTP Response

I'm trying to have my backend create a poll for a given user and when the user responds to the poll receive the response on the backend. However I cannot find a way to do the second part with an API available.
I know I can use Incoming Webhooks to send a command to users slackbot channel: /poll .. ... ... however I'm unsure how to receive a response from when user selects one of the options in the poll.
OK, one approach would be
Slash command for the /pollcommand, it will send a request to your app every time a user enters the command
Your app can then sends the actual message containing the poll details back to the channel incl. message menus simply by responding to the slash request or with Web API e.g. chat.PostMessage
User chooses polls option from message menus. Chosen option is send back to your app by Slack.
This is just one approach. Alternatively you could also show the options as message buttons or open a Dialog for the user.
I would advise against using outgoing webhooks, since its no longer part of the main features (and slash commands and interactive menus will send a request directly to your app anyway). Also Web API / chat.PostMessage is better than Incoming webhooks.

Slack POST multiple messages to a channel at once

I need to post multiple bot replies (responses determined dynamically) to the same channel.
The obvious way seems to be to do an HTTP POST for each message in succession using this API method: https://api.slack.com/methods/chat.postMessage
Is there a way to send messages to Slack in bulk to post to the same channel? The order in which the messages get rendered need not be important for me.
No, there is no bulk variant. So you basically need to build your own bulk message sender.
Keep in mind that there is a request limit of 1 message per second or your API requests will fail.
There also is a 3 seconds request time-out for many requests between Slack and your app. (e.g. for direct response to slash commands). So if your bot needs to send many messages you want to use an approach that allows you to send them asynchronously.
One solution to this problem that works very well for me is to use a messaging queue for all Slack messages sent from my bots.
You can try multiple messages as attachements -> https://api.slack.com/reference/messaging/attachments

Resources