Iframe integration: Sending commands
    • Dark
      Light
    • PDF

    Iframe integration: Sending commands

    • Dark
      Light
    • PDF

    Article summary

    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'
    }, '*')


    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.
    ESC

    Eddy AI, facilitating knowledge discovery through conversational intelligence