How to access Wix Chat/chatbox API events

Hi,

Very pleased to see the Wix Chat API being exposed. However I may be missing something important as I don’t seem to be able to access events such as onMessageSent. If I try to add this to the site code then the only events which appear for $w(“#myChatbox”) are onMouseIn, onMouseOut, onViewportEnter, onViewportLeave.

I’ve added the events regardless and am writing out to the console if they are hit, but nothing gets written out so I assume the event handler is not being recognised.

Any ideas please?

Many thanks,

Jerome.

1 Like

So you have seen the Chatbox API.
https://www.wix.com/corvid/reference/$w.Chatbox.html

Currently, you do only have the event handlers of onMouseIn and onMouseOut and onViewportEnter and onViewPortLeave for the Wix Chat app.
https://www.wix.com/corvid/reference/$w.Chatbox.html#onMouseIn
https://www.wix.com/corvid/reference/$w.Chatbox.html#onMouseOut
https://www.wix.com/corvid/reference/$w.Chatbox.html#onViewportEnter
https://www.wix.com/corvid/reference/$w.Chatbox.html#onViewportLeave

Don’t forget too that the onMessageSent function will only work when a user sends a message through the Wix Chat app.

https://www.wix.com/corvid/reference/$w.Chatbox.html#onMessageSent
onMessageSent( )
An event that fires when a site visitor sends a chat message.
Description
The onMessageSent() event handler runs when a chat message is sent. The sent Message object contains information about the message that was sent.
Note
onMessageSent() runs if the message was sent via the chatbox widget.
It does not run if the message was sent programatically using sendMessage() .

Examples

Get message data when a chat message is sent

$w("#myChatbox").onMessageSent((message) => {
  const channelId = message.channelId;
  const messageText = message.payload.text;
});

/*  Example message object:
 *
 *  {
 *    "channelId": "23b345b6-c78d-9012-e3f4-567g89h0i01k",
 *    "type": "TEXT",
 *    "summary": "Hey, how's it going?",
 *    "participantId": "12a345b6-e78f-8011-f3f5-567g89h0i12j",
 *    "createdAt": "2019-10-27T06:02:12.008Z",
 *    "payload": {
 *      "text": "Hey, how's it going?"
 *    }
 *  }
 */

Having the same issue trying to access this API. All of the channel functions are missing.

We need to get access to the chatbot to make sure that we’re able to get the response.

Make sure that you are testing it in a fully published live site and not through the preview.

There are issues within the Wix Chatbot API that are being addressed very soon like maximize not showing as a function in code, however it works fine when site is live.
https://www.wix.com/corvid/forum/community-discussion/open-chat-widget-when-button-is-clicked

Thank you #givemeawhisky whilst the editor doesn’t recognise the onMessageSent event it worked when I published the site. I had tested with a candidate release and it hadn’t worked in that mode. I have also removed wixChat and readded the app, so not sure whether it was doing that, or if it just doesn’t work in candidate release mode. Either way thank you for your replies.

1 Like

Yes let’s hope that the quirks in the API are sorted out soon as it isn’t great that it works on a live site and yet says that it doesn’t work in preview mode.

If that is a case like the Wix Users API where it only works fully on live sites, then it needs to be noted in the API section for it.

Anyways, I didn’t notice your profile name when I replied, I’m actually not that far from you and go back a good few years I would have gladly jumped to pop over and get into a kayak!

Although I was just an amatuer when I was doing it myself just a bit further up country (it was my brother-in-law and another friend who were the qualified bcu instructors), I always enjoyed it whilst doing it alongside my pulling (rowing), powerboating and sailing.

Unfortunately had to give it up due to work and family commitments, however from your own website, it looks like you get a great turnout down there, do you do a New Year’s Day paddle by any chance? Always a great way to get out of the house and the fresh air cures a hangover😉

@givemeawhisky this time of year it’s mostly peer trips, and generally on whitewater, though a few prefer flat water touring, or will head out sea kayaking. I expect someone will post in the forum shortly about a New Year paddle. Your best bet is to sign up to our website and check out the peer trips forum. Hopefully see you back out on the water soon.

1 Like

@totnescanoeclub

Thanks for that little bit of info, we were mostly out in the Bristol Channel around our own harbour or in the outer harbour or the marina itself when the tide was out. Otherwise, we’ve had a lot of years spent taking our own groups of kids back and forth between RN bases in Poole and Brownsea Island and avoiding the shipping lanes and the ferries that obviously wouldn’t have stopped for us!

Those were the days when you would sit on the water and just listen to the vhf radio and overhear the people who had brought boats like a small yacht or speedboat and not have a clue what to do with it when out on the actual water or how to properly use the radio, many times we chuckled when the harbour master or coastguard mentioned that they would pop down to the harbour when they got back in and have a little chat with them.

Thanks again. :+1:

1 Like