wixChat_onMessage does not trigger at all

I have a backend events.jsw that attempts to echo the message from the vistor. The code is written as below.

I published the code and then test it with the WixChat. It doesn’t work. The onMessage was never called when visitor post on the WixChat. What’s up?

import wixChatBackend from 'wix-chat-backend';

export function wixChat_onMessage(event) {

    const message = event.payload.text;
    const participant = event.participantId;
    const channelId = event.channelId;
    // const direction = event.direction;

    // if (direction === "VisitorToBusiness") {
        wixChatBackend.sendMessage({
            "messageText": `echo ${participant}: ${message}`,
            "channelId": channelId,
            "sendAsVisitor": false,
        })
    // }
}

Same fight here, I hired one develloper to do this connection with Open AI and He broke his tooth on it, yesterday I spent probably 8 hours straight with my GPT assistant to solve this issue myself, but it seems that WIX are blocking the entry…

So we are basically doomed to fail.

Here is my GPT assistant answers to this… he is a bit gangsta ahaha

:skull::skull::skull: BRO, THAT’S IT. WIX CHAT IS OFFICIALLY DEAD. :smoking::fire:

:x: “Wix Chat API is not available.”

Translation: Wix has completely BLOCKED developers from sending messages inside Wix Chat.


:fire: TIME TO BURY WIX CHAT FOREVER

:headstone: RIP Wix Chat (Cause of Death: Useless AF)
:wastebasket: DELETE wix-chat.jsw from your backend (it’s useless now)
:no_entry_sign: NEVER TRUST Wix Chat Again

And here is what we did try, I give the mic back to my GPT assistant again:

:x: The Wix Chat + ChatGPT Integration Is BLOCKED in Wix Studio

We tried every possible way to make Wix Chat work with AI responses, and it’s 100% blocked by Wix Studio. Here’s what happened:


:rocket: What We Tried & Why It Failed

:one: Standard Wix Chat API (sendMessage)BLOCKED.

  • Error: “Wix Chat API is not available.”
  • This means Wix prevents developers from sending messages via code.

:two: Backend Function (wix-chat.jsw) to Send AI RepliesBLOCKED.

  • Even when calling Wix’s own chat functions, nothing works.
  • Error: “Cannot read properties of undefined (reading ‘sendMessage’).”

:three: Full OpenAI Integration with Backend (chatbot.jsw)AI gets responses but can’t send them back.

  • The chatbot receives a response from OpenAI, but Wix Chat won’t display it.
  • The API logs show the message being generated but failing to send inside Wix Chat.

:four: Testing Automations in Wix Inbox Settings

  • Auto-replies work (BUT only with preset static messages).
  • No AI responses allowed.
  • No real-time AI chat possible.

:bulb: Questions for the Wix Developer

:one: Did Wix Studio remove sendMessage intentionally?

  • If yes, is there any workaround or alternative API method?

:two: Is there a hidden way to inject AI messages into Wix Chat?

  • Example: Maybe through a webhook, database update, or another trick?

:three: Is there any upcoming Wix update that will fix this?

  • Or is Wix permanently blocking developers from modifying chat messages?

It seems that I am not the only one trying this, and we literally tried thousands of options, including building our own chat by ourselves, but I have to admit I gave up at that point.

Hope that helps moving things forward.

Hi! I think you have your code in the wrong place - it should be in an events.js file.

Here’s an example I have from integrating tensorflow into Wix Chat - you can ignore that part of the code, but this file should give you a clue of how to structure this properly

and here is where i’m creating the message and sending it back to the chat

events.js is a reserved file name in Wix/Wix Studio - so it must be structured and named this way or it will not fire

Here is some more information and a video on how to use backend events that may help as well About Backend Events