Skip to content
This repository was archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
36 lines (24 loc) · 1.36 KB

File metadata and controls

36 lines (24 loc) · 1.36 KB

Iframe integration: Sending commands

When integrating an iframe into Rocket.Chat, you can also send commands to the embedded content using the postMessage Rocket.Chat API. It allows you to interact with the content in real time and perform various actions.

Available commands

Command Params Description
go - path string Change url
login-with-token - token string Allow login with token
call-custom-oauth-login - service string Allow login via oauth methods
set-user-status - status string Set the status of the user
logout Log the user out of their current session

Here is an example of how to send a command through a Rocket.Chat iframe:

document.querySelector('iframe').contentWindow.postMessage({
  externalCommand: 'go',
  path: '/admin/General'
}, '*')

Another useful example is setting user status in an iframe embedded in Rocket.Chat :

document.querySelector('iframe').contentWindow.postMessage({
  externalCommand: 'userSetStatus',
  status: 'away'
}, '*')