Question: I created a chat messenger between my website users based on wix repeater when a new msg launch a new row insert into chat collection (my chat collection including the following fields User A, User B, MSG ) and the messenger repeater should refresh for both users. 

So if user A send a message to User B 

I should do the following : 

1. a new row inserts into DB.
2. User A repeater is refresh.

**3. Refresh user B repeater** 

What is the best way to Refresh user B repeater? 

I used [afterInsert()](https://www.wix.com/corvid/reference/wix-data.Hooks.html#afterInsert) to know which user received a message and when but now I need to send this user a trigger for a refresh. 

I thought about sendMessage function after insert to this specific user and then refresh User B repeater when a new msg received [(use onMessage )](https://www.wix.com/corvid/reference/wix-chat-backend.Events.html#onMessage). the main problem is that I don't use wix chat so I can't generate channelId, If there was an option to send a message from a business to a specific user without channelId or alternatively get channelId without using wix chat app, it will solve this problem. 

What should I use ?

Answer: 
You can use the [Realtime API](https://www.wix.com/corvid/reference/wix-realtime.html) to create a subscriber for the collection on the client. In your backend code in the afterInsert function, publish a message to the specific client which execute the refresh function for the list in the repeater in the callback function. You could store the channel information for the client and backend to know each other alongside your message in your chat collection.
The best thing you can do is here is to set a setInterval() function under the page's onReady() function to refresh user B's dataset/repeater every 3-5 seconds which would check for fresh messages.