You could also try to use MQTT with anvil. There are Demo Codes availabe like
here: MQTT sample code
and
here: MQTT Made Simple [Websocket]
for testing purpose you can use the public mqtt broker : broker.emqx.io
It is just an idea to use mqtt which also might be a good fit for a chat application.
Good luck!