Wix Chat: Accessing Messages

Hey there,

If you’re familiar with coding, this shouldn’t be too difficult for you (:

Turn on Dev Mode in your website. Then from the Code Panel on the left, under Public and Backend, click on Handle Backend Events.

This should add a new file to your code panel called events.js

Click on the Wix Chat icon, and from the properties section in the code panel, add the export function named wixChat_onMessage. This will add a bit of default code in the file.

Replace the code with the one below:

export function wixChat_onMessage(event) {

  const message = event.payload.text;
  const participant = event.participantId;

  if (message== "Hi") {
  //execute your function here
  } else  if (message== "ABCD") {
  //execute your function here
  }

}

In this way, you can trigger various events based on the message received.

1 Like