Xano and Weweb chat creation

Hello! Just a quick question everyone!

I have my Xano Auth set. Obviously, I am also using the Xano database.

As I am trying to build AI tool and I am currently struggling with one thing!

I am building a list with 2 chat messages nested in a separate containers. One for user and one for system.

How to integrate the chat to display the messages in certain conversation and when I click on another conversation to automatically refetch the data?

Heya! Can you give us a bit more information? What tables are you using right now, how are you grouping messages together? Do you have a screenshot of your UI to help us understand that better too?

My chat system has 3 tables: messages, conversations, conversation_participants (and users ofc)
So I have an API that does a GET request for a certain conversation ID, and pulls the thread from the messages table that match that conversation. On the left I have a list with all the conversations that the user is a participant of. When you click on the conversation, the workflow re-fetches the Messages table with the new conversation id that was clicked.

Thanks a lot!

I am using:

conversations messages

user(of course)\

May I just ask did you use a separate variable to hold the currentconversation ID clicked so you can refetch the message and convo collection based on it?(Asking, beacuse I use that but it’s Kinda slow).

Also, I am struggling with adding all the messages from the assistant and user. It displays only the first text. How can i fix it? And how to filter it by role?

I have the same problem

I’m not sure (again) what your problem is exactly since you haven’t really provided much context about what you have now and how things are working now. What I do: Like I said I have an api for conversations and one for messages. On page load, I have 2 workflows. The first one sets the variable “conversation_id” to the one of the first (most recent) conversation that is pulled, and then fetches all the messages for that conversation. I’ve put that fetching in a While loop which: Fetches the messages, calls the ‘mark as read’ api, has a 10sec delay, then loops over it.
When you send a message, it also fetches the messages, so first it posts the message with the ‘post new message’ API, then refreshes all the messages. meanwhile the loop is running so you will receive new messages on every poll.

The second on load workflow is similar, it’s a while loop that checks if we’re on the Messages page, and polls all conversations every 10sec.

When someone clicks on another conversation, the variable conversations_id gets updated, so the polling of messages changes to another conversation. I also do one refresh on that click so you don’t have to wait until the loop runs again.

The screenshots are red because this example doesn’t have any messages yet