How to send chat message in BigBlueButton throught javascript?

99 views
Skip to first unread message

Greg Link

unread,
Aug 23, 2022, 3:10:35 AM8/23/22
to BigBlueButton-dev

I'm using BBB and have a custom javascript script executed. I want to use the public chat to log when users leave the page and come back.

As I don't understand which function needs to be called to send a message I'm trying to use the chat html elements. First I add a message to the text area:

document.getElementById('message-input').value="my message";

Then I try to send the message:

document.getElementById('message-input').dispatchEvent( new KeyboardEvent('keydown', { bubbles: true, cancelable: true, keyCode: 13 }) );

But the message isn't sent. I tried to send input and change message before sending but that doesn't work:

document.getElementById('message-input').dispatchEvent( new Event('input')); document.getElementById('message-input').dispatchEvent( new Event('change'));

Thanks

Brent W. Baccala

unread,
Aug 23, 2022, 6:20:18 PM8/23/22
to BigBlueButton-dev
I think that's going to be somewhat difficult.

To do it the way you're thinking, this is how you can click the button:

document.querySelector("button[data-test='sendMessageButton']").dispatchEvent(new MouseEvent('click'))

The problem is that this code assumes that the chat window is open and the send message button is visible.

I think a more reliable way would be to publish a message into the Redis database.  That's how bigbluebutton-html5/imports/api/group-chat-msg/server/methods/sendGroupChatMsg.js does it.

To do it that way, you have to be authenticated into the Meteor session between the client and server, so it's a good bit more work.  The BigBlueButton client does that, of course, but it doesn't export a function that can be easily called from a script.

If I was going to do it, I'd probably build a custom BigBlueButton client that provides something very much like sendGroupChatMsg from bigbluebutton-html5/imports/api/group-chat-msg/server/methods/sendGroupChatMsg.js, but makes that function available for use from a script.

Probably a lot more involved that you (or I) would care for it to be.

    agape
    brent

Gregory D.

unread,
Aug 24, 2022, 1:45:05 AM8/24/22
to bigblueb...@googlegroups.com
Ok it seems I will have to find another idea :-) Anyway, thanks for your help !


--
You received this message because you are subscribed to a topic in the Google Groups "BigBlueButton-dev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bigbluebutton-dev/Dyr6Z5Dg48E/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bigbluebutton-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bigbluebutton-dev/72680f9e-11d1-4de1-8c91-2cbdeca28e6fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages