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