Sending messages with iFrame API

Hi @everyone,

I’m trying to send a chat message to a specific participant or a group with Jitsi’s iFrame API:

api.executeCommand('sendEndpointTextMessage', 'receiverParticipantId', 'text');

or to all:

api.executeCommand('sendEndpointTextMessage', '', 'text');

Both didn’t worked for me - nothing happend and no error caused in console.

I searched the community postings at jitsi.org and also the stackoverflow entries, but couldn’t find any solution, even though I’m not the only one, who have this problem.

So I tried to do it the “manual” way: Set the value of the input textarea and simulate an enter event.
Nothing happened, so I analyzed the event listeners of the textarea and found out that it’s waiting for a keydown event. Unfortunately I read, that for security reasons browser don’t allow simulation key events to input fields.

Now I only have 2 ideas left, but maybe there is a better way to do it???

  1. Chancing the listing event from keydown to onchange and define a special keycode to trigger the enter event.

  2. Adding another text chat application on the same OS with nginx reverse proxy config and use some restfull service requests for communication.

Does anybody have a suggestion? :slight_smile:

1 Like

Hi there,

I am having same issue. I am curious to know how did you solve it.

Hi @sanjitkung,

I couldn’t get this iFrame function to work, but I build my own workaround:
Depending on what you want to send via chat, it’s probably not the best solution to use a simple text chat. In my case I wrote a simple java spring application and let my fronted send a POST request to the application every time interval.

To avoid cross domain policies I used Nginx reverse proxy functionality. Jitsi using it, too. So you only copy a location entry in /etc/nginx/sites-enabled/look-file-name-up.conf to map your additional application from https://domain.com:8443 to https:domain.com/my-application.

If you really need a textchat you can use the same solution with nginx too and and host a open source textchat application.