Salesforce Live Chat api concurrent requests - ajax

I've tried to extend my chatbot with salesforce live agent api. So I've implemented all the process, and chat works correct, except one thing - It won't work on multiple tabs. When one tab have long polling connection (left side on the screenshot), and I open new tab (right side) - old tab (left) receive:
409 Conflict
Duplicate Message Observer
Is it possible, and can I use multiple tabs with salesforce long polling connection on my online shop? (it is general situation, when customer has many tabs, and each of them should be with the same chat)
I use salesforce Messages api endpoint: https://developer.salesforce.com/docs/atlas.en-us.live_agent_rest.meta/live_agent_rest/live_agent_rest_Messages.htm

You can't work with multiple tabs on the Salesforce. You can make the backend part, where you can make a locker. (only one request pass to the SF, but all other waits for the master-request

Related

network tab in chrome doesnt update for every request sent

so for instance, this is difficult to explain but i will try to my best ability.
if you refresh a page on for instance a discord channel, an ajax request is sent to:
https://discord.com/api/v8/channels/channelidhere/messages?limit=50
which gets the last 50 messages sent in the channel. now, interestingly enough, if youre in a channel with lots of new messages being sent the netwrok tab does not update as if there were no requests associated with the channel messages being updated. ive seen this happen with other sites in similar ways and im just curious as to what i may be missing, is there some reason a request would be sent that the network tab doesnt catch? ps: even if i go to the all tab which supposedly captures all requests still no bueno.
It's common that chat website use websockets instead of http to communicate.
maybe this will help you How do you inspect websocket traffic with Chrome Developer Tools?

Symfony3.4 - Send a Server-Sent Event when something happens

I'm developing a project with Symfony 3.4.
I would like to send a message to all the clients currently viewing a page when something happens. I evaluated both Server-Sent Events and Websockets, and I decided to go with the former, because the communication is unidirectional (only server to client).
For this purpose, I'm using this library: https://packagist.org/packages/tonyhhyip/sse
It seems to work, but I need to specifically send a message when something happens in the whole system. I tried with the Symfony event system (by creating a custom event), but events seem to be dispatched and captured only within the same session (i.e., the same logged user). In other words, if an action performed by a user triggers an event, it is not captured by other users and therefore a message is not sent to the browser via SSE.
Any suggestion?
Thank you

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.

Quickblox - Listener Firing Multiple times

I'm using Quickblox in Ionic (Angular), with Parse for my database. Whenever I send friend requests, it only sends one, and the receiver only receives one, but the listener goes off some random number of times (3-10), Consequently, if I send a chat, it will send the same number as there are friend requests. However, if I hard-code in the user who sends and receives chats, it the chat receiver still does the same thing.
I'm using Parse to manage Quickblox accounts. So I'm fairly theres some issue with session management and connections to Quickblox.

Callback methods in ASP.NET Web API

I have an ASP.NET Web API server, that have to communicate with different applications on different platforms. And now I want to create a method that would be something like a callback: client application subscribes to it and waits until server fires a message.
Example:
Many users are waiting until new product will be available in store - they subscribe to this "event". When product arrives in store - every customer receives a message, which have to be handled in some case.
Users send a request "Subscribe"
Server receive a request "Product available!"
Server sends every user a message with product details.
User's application processes the message
I tried to find some information about callbacks or duplex in ASP.NET Web API, but the one advice - it's better to use WCF for this approach.
Solutions
In every client application create something like timer, that every N seconds sends a request "Is product available?" until gets "false". When the response will be true - send a message "Get product details". It's causes a lot of traffic and if there will be many clients with these timers - it would be something bad, isn't it?
Create a small callbacks-server (maybe WCF). But in this case would be a lot of problems with communication between this server and apps on different platforms.
Maybe there are some solution in ASP.NET Web API, that i missed.
If you have some ideas how i can solve this problem, please give me an advice.
Thanks for help.
Looks like you want push notifications from your server - which, in this case, can be achieved by combining SignalR with Web API.
Brad Wilson has a great example on this:
code here - https://github.com/bradwilson/WebstackOfLove
NDC Oslo talk explaining all this - http://vimeo.com/43603472
In short, whenever you add new item to the Web API, you can notify all the connected (subscribed) clients:
public void PostNewItem(ToDoItem item)
{
lock (db)
{
// Add item to the database
db.Add(item);
// Notify the connected clients
Hub.Clients.processItem(item);
}
}
SignalR will invoke the processItem function on the client.
Alternatively, you might want to look into JavaScript SSE and Web API PushStreamContent but that is much more low level and SignalR abstracts a lot of this type of stuff for you so it might be more complicated to deal with.
I blogged about this approach here http://www.strathweb.com/2012/05/native-html5-push-notifications-with-asp-net-web-api-and-knockout-js/

Resources