Listen to event

Implémenté

document.addEventListener('DOMContentLoaded', () => {
  const rofimChatWidget = document.querySelector('rofim-widget');
  rofimChatWidget.addEventListener('m.rofim.message', (e) => {
      const widgetId = event.target.id;
  		// handle status events according widgetId.
		});
});

The Rofim Chat Widget component emits a different set of events that the Establishment may listen.

  • m.rofim.ready: Emitted when the widget is ready to be used.
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0,
		"m.rofim.ready": {
				"m.rofim.room.singleroomID": undefined,
				"m.rofim.room.failureReason": undefined
		}
}

When an error occurs at startup, the root cause is given by the ready event

{
    "m.rofim.ready": false,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": undefined,
    "m.rofim.unreadMessages": 0,
		"m.rofim.ready": {
				"m.rofim.room.singleroomID": undefined,
				"m.rofim.room.failureReason": 'some error occured'
		}
}

When the widget is operated with operationmode SINGLE_ROOM and is given the singleroomid alias, the ready event gives the genuine room id to interact with the room

{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0,
		"m.rofim.ready": {
				"m.rofim.room.singleroomID": '!ZMQodzfmXcezPlCimx:preprod.rofimoncloud.com',
				"m.rofim.room.failureReason": undefined
		}
}


  • m.rofim.new-message: Emitted when a new message is received.
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 1,
    "m.rofim.new-message": {
        "m.rofim.room.roomID": "!qgjvQXNSbWiLcpsSYq:staging.rofimoncloud.com",
        "m.rofim.message.from": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
        "m.rofim.room.unreadMessage": 1
				"m.rofim.message.type": "TEXT"
    }
}


  • m.rofim.all-notifications-have-been-read: Emitted when all notifications have been read.
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0
}


  • m.rofim.message-read: Emitted when a message have been read in a room
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0,
		"m.rofim.message-read": {
				"m.rofim.room.roomID": "!ZMQodzfmXcezPlCimx:preprod.rofimoncloud.com",
				"m.rofim.room.unreadMessage": 0
		}
}


  • m.rofim.lightbox-deployed: Emitted when the widget is deployed (lightbox mode only).
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0
}


  • m.rofim.lightbox-folded: Emitted when the widget is folded (lightbox mode only).
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0
}


  • m.rofim.notifications-enabled: Emitted when the user enables push notifications.
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0
}


  • m.rofim.notifications-disabled: Emitted when the user disables push notifications.
{
    "m.rofim.ready": true,
    "m.rofim.displayMode": "EMBEDDED",
    "m.rofim.userID": "@marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
    "m.rofim.unreadMessages": 0
}

Reste à faire

  • m.rofim.invited-to-room: Emitted when a user is invited to a new room.
{
  elementType: 'm.rofim.chatWidget',
  m.rofim.ready: true,
  m.rofim.unreadMessages: 24,
  m.rofim.displayMode: "lightBox",
  m.rofim.userID: "marc-antoine_rofim.doctor:2345678987654.rofim.doctor",
  m.rofim.room : {
    m.rofim.room.aliasID: "2345678654:2345678987654.rofim.doctor",
    m.rofim.room.displayName: "blabla",
    m.rofim.room.actType: "m.rofim.te",
    m.rofim.room.actID: "34TYUIUYTREFGHJ"
    m.rofim.room.actURL: "https://patien.com"
    m.rofim.room.unreadMessage: 2,
  }
}
  • m.rofim.member-joined: Emitted when a member joins a chat room.
  • m.rofim.member-left: Emitted when a member leaves a chat room.