Custom Notification to selected participants

Hi
We are consuming external API and would like to send custom notifications to participants.
From our web app we will call this function and would like to send custom notifications to participants passed in the array

I have exposed one function in external_api like below

 showCustomNitification(participants, message) {
        return this._transport.sendRequest({
            name: 'show-custom-notification',
            participants,
            message
        });
    }

Then in API.js

transport.on('request', (request, callback) => {   
case 'show-custom-notification': {
           const {participants, message} = request;
            callback(App.Conference.);
            break;
        }

In Conference.js

//Would like to iterate the participants and dispatch below Notification

APP.store.dispatch(showNotification({
                        titleKey: 'custome message',
                        descriptionKey: 'custom message'
                    }, NOTIFICATION_TIMEOUT_TYPE.SHORT));
                });
}

How can Iterate and send Notification to only participants passed in the array ?

You should probably do it differently: use an endpoint message and send a message to the participants you want to create a notification for, and they, upon the reception of the endpoint message create a custom notification locally.

Hi Sagul

Thanks for your reply
I did not get on what an endpoint message is , can you provide some example reference here
How to create an endpoint message and send a message.

If you point me here any existing workflow from Jitsi-Meet I will try to debug the code.

See here: Commands | Jitsi Meet

Hi Saghul
@saghul
Thanks , makes some sense now

Can I define my own Command or use the “end-endpoint-text-message”
Hope form where I am using this (my web app) I can iterate the participants and call the executecommand in a loop

And I guess when I use “executecommand” it will be received in the below code in /conference.js
but ENDPOINT_MESSAGE_RECEIVED is not getting triggered.

 room.on(
            JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
            (...args) => {
                APP.store.dispatch(endpointMessageReceived(...args));
                if (args && args.length >= 2) {
                    const [ sender, eventData ] = args;

                    if (eventData.name === ENDPOINT_TEXT_MESSAGE_NAME) {
                        APP.API.notifyEndpointTextMessageReceived({
                            senderInfo: {
                                jid: sender._jid,
                                id: sender._id
                            },
                            eventData
                        });
                    }
                }
            });
  • Where could I show the CustomNotification, should it be in the react/features/subtitles/middleware.js ? function _endpointMessageReceived(

You can define your own, it’s free form.

Yes, the recipient should see this. Are you executing the command with the right recipients?

Since you are defining this yourself, no big deal, I guess you could that wherever feels easier for you.

Thanks Saghul

can we run api.executecommand(…) in a for loop from a web app?

sure thing!

Hi Saghul
@saghul
I am unable to read the data passed form below command, is the below format correct
API.executeCommand("sendEndpointTextMessage","dc1ab555", "Test");

Also I would like to pass a flag in the above command to show the notification or not like below

API.executeCommand("sendEndpointTextMessage","dc1ec555", "Test", showNotify);

I would like to show the Notification in below function only

JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
            (...args) => {

How could I parse the args to get PartID, Text and Flag ?

Yes, this looks about right. Do you not get the event in the recipient?

You can JSON-encode it in the text field, for example.

@saghul
How Can I define my own ENDPOINT_MESSAGE_RECEIVED event
something like below
JitsiConferenceEvents.ENDPOINT_CUSTOM_MESSAGE_RECEIVED

In which areas should I make the changes ?

You don’t need to define a custom one, just put your own payload and parse it on the other end.

@saghul

Thanks, Appreciate your response.
One change in our requirement, can I pass array of Participant ID’s

I believe this ENDPOINT_MESSAGE_RECEIVED is triggered for each participant, I am looking for a way to send Participant Array. I know that passing “” will send to all the participants but would like to pass an array of Participants
Is there any method currently that supports this

Call the function in a loop, which will send each participant you want the message.

@saghul
You mean calling the executeCommand(…) in a loop ? I tired that and it works fine but I would
like to send the participant array to executeCommand(…) and handle in the Jitsi-Meet repo

Can this be achieved ?

This API will send a message to ONE participant. You can’t trigger a remote notification, so you’ll send the message to everyone, then EACH of them will locally triiger the notification.

@saghul

From your statement “so you’ll send the message to everyone, then EACH of them will locally trigger the notification.”

How could I send the message to everyone and how could each of them who received the message trigger the notification. is there any particular event that sends the message to everyone ?

Sigh, I worded that wrong. You send the messsage to each participant you want to display a notification for. They then display it locally. This last part is where your custom code in conference.js does it.

@saghul
You have answered a lot in this thread and would like to close this with below

In layman terms we cannot pass array of participants to executeCommand(sendEndPoint…)

And Current Jitsi Meet Architecture behaves in a way that message is sent to each participant and not array of participants at once

Correct.