How to get chat hostory SessionID Data from API.AI/Dialogflow? - dialogflow-es

I have integrated API.AI in my website as chat box. When I browse other pages of the website, the chat history vanishes as expected. How can I retain these history data? How can I keep track of the current sessionID chat history?

Related

No XEP-0333 Chat Markers in XMMPP Openfire backend - how to solve it?

We have an Openfire XMPP/Jabber server setup (with a NodeJs backend and React frontend).
Chat is a feature embedded in the app (NOT an overlay or window that is always visible). So the user has to navigate to a specific page to access the chat interface.
It is working via websockets and messaging sending is working fine. We have a React frontend.
The challenge is that XEP-0333 Chat Markers is not supported by Openfire (the spec never become production ready).
Therefore we need to know how can we implement this feature so that :
A users knows when they are online that they have an unread message (and later, how many unread message they have). For example, if they are not in the chat window and messages are arriving, we need to indicate that in the header of the app so they see it)
if a user goes offline, and comes back online but NOT into the chat window, how can we know if they have unread messages and notify them of that?
My understanding is that somehow we have to keep track of unread messages (eg perhaps in indexedb or local storage or even in postgres backend) and after the user reads a message, we delete it from storage. If the storage still has records for that user then clearly those are the unread messages.
Obviously we don't know if they actually READ the message, but we can assume that if the chat window is open and visible (ie. active tab in their browser) that any messages delivered have been read.
So if our application tab is active, but user is not in chat, and a message arrives, we store it. When they open chat and click on the sender, we remove it from storage.
Has anyone solved it this way? (looking for links to React or JS/TS code)
Is there a better way? (links to other solutions would be helpful, esp. code)

Is it possible to store messages in a socketio chat app

Let's say I made a complete UI of a chat app. We have a panel which contains all the recently contacted. We have react on the front-end and node, express on the backend. The real time data transfer chat is carried out using socketio.
The real question is how do I store all the messages that I have with each user. Let's say I chatted with user A for a while, closed the tab and moved to user B. Then the next day I moved back to the user A, I want all my previous chats with that user to be available to me.
How is that achievable?
One way I can wrap my head around is that I use mongoDB to create a chat room with two specific user and a id. Then I store that room on mongo with all the chats stored in an array.
On the client side, I check the db if a specific chat room exists. If it does, I send all the messages in to the client side, if not it create a new chat room.
This is by far the most sensible thing I've thought.
Any guidance as to what other techniques I can use?
Much appreciated.

Private chat app which saves contacts/message history with MongoDB Nodejs Socket.io and Redux

I'm quite new with sockets so I came here to ask for some good practice ideas.
To understand better what I want to achieve here is my idea: I made a product creation page in react which has a seller and an option "Send message to the seller". After a buyer clicks to this button I want to make a private chat between the two user.
I want to save this socket connection and all of the messages between the users for both of them in my MongoDB database. So whenever a user simply leaves the site all of the recieved contacts/messages are saved and when he rejoins can continue the chat with the pre-loaded chat history.
So I thought about creating a messages collection and store socket details in document like this:
_id:ObjectId("123")
productId:1
sender:id1
reciever:id2
messages=[{1:"Hey},
{2:"Nice to meet you"} ...]
And here comes the redux part: When a user is logging in, I want to fetch all of the previous contacts and messages so he can continue chatting with them. But it would be time waisting to fetch the message history every single time, so I thought about using a redux store to get the contacts and history from database and store there. Like this
recievedmessages=[{_id:ObjectId("123")
productId:1
sender:id1
reciever:id2
messages=[{1:"Hey},{2:"Nice to meet you"} ...]},
{othermessage1 ...},
{othermessage2 ...},
]
sentMessages=[{sentmessag1, sentmessage2, sentmessage3}]
And when a buyer sends a new message to that user I update my redux store for the buyer, when the seller recives the message from the socket update for him too and lastly my chat history in my mongodb messages field for that specific document. --> I am not sure at this part to have to manage it
Is this a good practice or how should I make this to be effiecent and store data? Thanks in advance.

Carousel in Bot Framework - continuously updating from database - upon scrolling it?

Is it possible that carousel in Bot Framework (where it is allowed - like Messenger, Bot Emulator etc.) updates continuously (according to a database from which it reads data) after it was initially rendered and sent as a message to the user - without rerendering the whole carousel and resending it to the user?
Something like - .onFlipHandRightOnCarousel or .onFlipHandLeftOnCarousel - delete void HeroCards (where in database they are flagged as 'inactive') from already rendered carousel and rerender this new carousel without resending a new session.send(msg) to the user?
Modifying messages that have already been sent means modifying the chat history. This functionality will be highly channel-specific as it depends on how the client handles the history and what the client allows users to do to the history. Many channels do not support this functionality but some do. Generally speaking, if you as a user can go back and delete or edit messages in the chat history then a bot can too. If you as a user cannot then you should not expect a bot to be able to do it. But if you're working with a channel that does allow history edits then I imagine you should be able to edit the carousels if those are also supported.

How to store and retrieve the chat history of the dialogflow?

I want to redirect the chat from Google dialogflow to a human. For this, I want to get the history of the conversation made by the user. Is there any platform where the history is being stored? If yes, how to access it. If not, how to achieve this functionality..
There's no current API to retrieve session history. The only alternative is to save the history yourself.
You can use any database you're familiar with, MySQL, MongoDB, or even a cloud hosted database such as Firebase Realtime Database
The code won't be too hard, everytime the user sends a new message and every time the bot answers, you will have to save that message to the database, with the right timestamp and chat ID.
When the user is redirected, you will get all the messages from that session using the chat ID, sort them by timestamp, and you will have your complete chat history available.
Some answers/tutorials that might help you:
Best way to store chat messages in a database?
Storing chat messages inside a MySql table
Firebase Web chat tutorial

Resources