This is doable but it takes quite a lot of digging since the documentation is uhmm bad and poorly written. Here’s what I did (Note that it’s close but It doesn’t work for me completely at this point)
First you setup an account in your rocketchat server that has admin privileges. You will use this account using REST calls to automatically create user accounts.
https://rocket.chat/docs/developer-guides/rest-api/users/create/
I would advise that this is done in a server you write, something in PHP, Pythin or JEE, because you don’t want to have these credentials floating around in your webpage.
Use the same code to log the user into your rocketchat instance with the newly created account:
https://rocket.chat/docs/developer-guides/rest-api/authentication/
You will get a JSON object back that has a token. You can then use that token to call postMessage on the iframe where you have rocketchat embedded, as per:
https://rocket.chat/docs/developer-guides/iframe-integration/commands/
I’m stuck on this one myself. This should all work according the documentation but I’m seeing an error in the iframe running rocketchat.