API

The RofimWidgetHTMLElement API allows a developer to interact with and manage the Sana from their web application.

This object has methods and emits events that the web application can listen to.

show()

Displays the chat widget.

When in LIGHTBOX mode, displays the fold/unfold button.

hide()

Hides the chat widget.

When in LIGHTBOX mode, hides the fold/unfold button.

toggleVisibility(): boolean

Toggles between showing and hiding the widget.

Returns

Returns true if visible, false otherwise.

deployLightbox()

Deploys the widget in LIGHTBOX mode.

Throws

Throws an error if the widget is not in LIGHTBOX mode.

foldLightbox()

Folds the widget in LIGHTBOX mode.

Throws

Throws an error if the widget is not in LIGHTBOX mode.

asyncgetUnreadMessagesNumber(): Promise<number>

Returns the number of unread messages.

Returns

Number of unread messages.

asyncmarkAllAsRead(): Promise<void>

Marks all messages as read.

Returns

No return value.

asyncsendMessage(roomId: string, message: AbstractMessage): Promise<void>

Sends a message in a room.

Parameters

roomId string required

roomId of the room to send the message to.

message AbstractMessage required

Message to send.

AbstractMessage
type: "TEXT" | "FILE"

Discriminator for the message type.

TextMessage
type: "TEXT"
text: string
FileMessage
type: "FILE"
securityToken: string
uploadFile: UploadFileBlob | UploadFileUrl
UploadFileBlob
type: "BLOB"
content: Blob
filename: string
UploadFileUrl
type: "URL"
url: string

Returns

No return value.

asyncsendFileMessage(securityToken: string, message: FileMessage): Promise<void>

Sends a file in a room.

Parameters

securityToken string required

securityToken obtained from the UploadCallback.

message FileMessage required

File to send.

FileMessage
type: "FILE"
securityToken: string
uploadFile: UploadFileBlob | UploadFileUrl
UploadFileBlob
type: "BLOB"
content: Blob
filename: string
UploadFileUrl
type: "URL"
url: string

Returns

No return value.

asynccreateRoom(roomCreationRequest: RoomCreationRequest): Promise<Room>

Creates a new room.

Parameters

roomCreationRequest RoomCreationRequest required

Room creation request.

RoomCreationRequest
roomName: string
membersToInvite: string[]
act: Act
Act
actType: string
actId: string
actUrl: string

Returns

Returns a Room object.

Room
roomId: string
name: string
members: string[]

asyncopenOrCreateRoom(request: OpenOrCreateRoomRequest): Promise<Room>

Opens an existing room with the specified users, or creates one if no matching room exists.

Parameters

request OpenOrCreateRoomRequest required

Room request.

OpenOrCreateRoomRequest
roomName: string

Optional name for the room if it needs to be created.

membersToInvite: string[]

Complete Synapse user IDs to include, such as @user:server.

Returns

Returns a Room object.

Room
roomId: string
name: string
members: string[]

asyncgetRoom(roomId: string): Promise<Room>

Gets the details of a room.

Parameters

roomId string required

roomId of the room to get.

Returns

Returns a Room object.

Room
roomId: string
name: string
members: string[]

asynclogout(): Promise<void>

Logs the user out.

The Sana Widget is removed from the DOM.

Returns

No return value.

asyncrequestNotificationsPermission(): Promise<void>

Asks the user for permission to enable push notifications.

Returns

No return value.

asyncdisableNotifications(): Promise<void>

Unregisters from push notifications.

Returns

No return value.

asyncisNotificationsEnabled(): Promise<boolean>

Indicates whether push notifications are enabled.

Returns

asyncsendResource(securityToken: string, resource: AbstractResource): Promise<void>

Sends a resource to the room associated with the security token.

Parameters

securityToken string required

Security token provided by the callback.

resource AbstractResource required

Resource to send to the room associated with the security token.

AbstractResource
type: "GENERIC" | "ACT" | "PATIENT"

Discriminator for the resource type.

cardIcon: string
cardTitle: string
title: string
description: string
linkLabel: string
url: string
payload: Object

Returns

No return value.