Chat

broadcast()

Broadcasts a message in the chat.
Message will be displayed to all the recipients of the chat

use cases : sending custom media (video, audio, GIFs), polls, call to actions

usage :

Chat.broadcast({
  text: 'Hello world',
  html: '<p>Hi</p>'
})
ParamType Description
text?StringThe text of the message
html?StringAn HTML template that will be rendered below the text

@returns An instance of the created Message that you can use to delete the message or be notified whenever the HTML posts message

send()

Adds a message in the chat.
Message will be sent locally, only to the connected user

use cases : sending user specific content (video, audio, GIFs), polls, call to actions, forms

usage :

Chat.send({
  user: {
    firstName: 'Michael'
  },
  text: 'Hello world',
  html: '<p>Hi</p>'
})
ParamType Description
userHashA hash with informations about the sender (firstName, lastName, avatarUrl)
textStringThe text of the message
htmlStringAn HTML template that will be rendered below the text

@returns An instance of the created Message that you can be used to delete the message or be notified whenever the HTML posts message

listen()

Be notified whenever someone posts a message in the chat.

use cases : chat bots, forwarding messages to another API (slack, intercom), language filter, translations, notifying moderators of specific things

usage :

Chat.listen(message => console.log(`Someone said ${message}`))
ParamType Description
callbackFunction(message)Function that will be called whenever the user posts a message

intercept()

Intercept Chat messages matching a specific regex.
Once intercepted, the message will not be displayed in the chat.

use cases : custom chat commands, trigger actions, chat bots, forwarding messages to another API (slack, intercom), language filter, translations, notifying moderators of specific things

usage :

Chat.intercept(/lol/, (message) => console.log(`someone said ${message}`))
ParamType Description
matcherRegExpA regular expression that represents the messages to be intercepted
callbackFunction(message)A function that will be called whenever a message that matches your criteria is intercepted

registerShareButton()

Register an entry in the Share menu of the chat.
Can be used to trigger any action (sharing custom content, files, videos, etc)

use cases : trigger actions that will affect the chat (sending files, starting workflows, etc)

usage :

Chat.registerShareButton({
  label: 'Share a Document',
  imageSource: 'http://image/image.png',
  onClick: () => console.log('someone clicked this button')
})
ParamType Description
labelStringThe label of the action 
iconStringAn icon from the icons list
imageSourceStringURL of an icon (png, svg) that will be displayed next to your button 
onClickFunctionFunction called whenever someone clicks on your button 

registerMessageAction()

Register an entry in the context menu of a chat message.
Can be used to trigger any action (sharing custom content, files, videos, etc)

use cases: message translation, actions specific to the user who sent the message

usage:

Chat.registerMessageAction({
  label: 'Translate this message',
  imageSource: 'http://image/image.png',
  onClick: (message) => console.log('someone clicked this button')
})
ParamTypeDescription
labelstringThe label of the action
iconstringAn icon from the https://feathericons.com library (not recommended)
imageSourcestringURL of an icon (png, svg) that will be displayed next to your button
onClickFunctionFunction called whenever someone clicks on your button

Buttons

registerStageButton()

Register an entry in the stage actions (for contributors and participants)
Can be used to trigger any action (sharing custom content, files, videos, etc).

🚧

If you use the dropdownActions param, the onclick function will no longer be called on a direct click to the button, but on a click on any of the dropdownActions, and it will be given the clicked action as param.

use cases : call to actions, custom workflows, action button

usage :

RegisterStageButton.register({
  label: 'React with an emoji',
  icon: 'smile',
  dropdownActions: [{ name: '😱', label: '😱' }],
  onClick: (payload) => {}
})
ParamType Description
labelStringThe label of the action
iconStringAn icon from the icons list
tooltipString A tooltip that will appear when hovering the button
imageSourceStringURL of an icon (png, svg) that will be displayed next to your button
dropdownActionsArray<{ name?: string, label: any, imageSource?: string }>,Actions that will be visible whenever the button is clicked
iframe{ template: string, variables: any, width: number, height: number, onMessage?: (payload?: any) => unknown, }a custom popover that will be displayed over the button when clicked on
onClickFunctionFunction called whenever someone clicks on your button

registerShareButton()

Register an entry in the Share menu for contributors.
Can be used to trigger any action (sharing custom content, files, videos, or starting any kind of process, etc).

usage :

RegisterShareButton.register({
  label: 'Share a Document',
  imageSource: 'http://image/image.png',
  onClick: () => console.log('someone clicked this button')
})
ParamType Description
labelStringThe label of the action
iconStringAn icon from the icons list
imageSourceStringURL of an icon (png, svg) that will be displayed next to your button
onClickFunctionFunction called whenever someone clicks on your button

What’s Next