Code Example: sending chat messages to anyone from backend

Good to mention, GOS!

I’ve got an addition to the code I gave for events.js. To also catch people that become a site member (in addition to users sending chat messages) change the onMessage eventhandler into the following

export function wixChat_onMessage(event) {
const participantId = event.participantId;
const channelId = event.channelId;
const direction = event.direction
const summary = event.summary
console.dir(event)
if (direction === "VisitorToBusiness" || summary === "Became a site member") { saveChannel(participantId, channelId) }
}