Take a look on gproc project: https://github.com/uwiger/gproc
It has a Pub/Sub pattern that you may use to build the chat you mentioned.
From gproc's wiki:
subscribe(EventType) ->
%% Gproc notation: {p, l, Name} means {(p)roperty, (l)ocal, Name}
gproc:reg({p, l, {?MODULE, EventType}}).
notify(EventType, Msg) ->
Key = {?MODULE, EventType},
gproc:send({p, l, Key}, {self(), Key, Msg}).