Auto-Send initial message to Livechat

Description

Hello, I am creating a web page which will have as an important base Rocket.Chat.

Every time a visitor enters my web page, I want the Livechat window to be open by default and an initial message with predefined buttons to appear first so that the visitor knows where to start.

This first message would be received by a Chatbot created with Rasa.

For the Livechat to appear maximized, I use the code:

<script type="text/javascript">
	RocketChat(function() {
	this.maximizeWidget();
});
</script>

So, I have tried and thought several possible solutions:

  1. Triggers. Triggers currently only allow you to put a message, but do not allow you to use predefined buttons connected using Payload (this may be a good feature btw).
  2. JavaScript. I had also thought of creating a function that simulates the user sending a message when chat is maximized using the following code:
	<script type="text/javascript">
	RocketChat(function() {
		this.onChatMaximized(function() {
			XXXXXXXXXX
		});
	});
	</script>

These two options I don’t think are possible in any way (if I’m wrong, please, correct me), so I have decided to study the addresses indicated here: https://github.com/RocketChat/Rocket.Chat.Livechat/issues/168

Using REST Api: The idea would be that every time someone enters the web, a visitor is registered through (/api/v1/livechat/visitor), then open a room (/api/v1/livechat/room), and with this have a token and a rid to be able to send a message from the user (/api/v1/livechat/message).

I’m not very familiar with running through REST APIs, so I would like to know where I should start to achieve the desired result.

How should I do so that every time someone enters my web page, the registration payload is executed with a random token and at the same time a room is created with a random rid using this same token and at the same time send the message using this same token and rid?

The ultimate goal is that the user, when entering the web, sees a text message and predefined buttons to be able to start the chat interactively. At first, everything will be carried by the Bot with Rasa, and if he decides to talk to an agent, pass it through Handover.

Server Setup Information

  • Version of Rocket.Chat Server: 4.4.2
  • Operating System: Ubuntu
  • Deployment Method: tar
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: 14.18.2
  • MongoDB Version: 5.0
  • Proxy: nginx
  • Firewalls involved:

Any additional Information

Hi! Sorry for the late response.

What you want to do is not currently supported with LiveChat Widget, AFAIK.

This could be a nice feature, while registering a new visitor with a payload. This would fit greatly on register visitor method:

I’ll check with our dev team if this is on our roadmaps or if there is a way for doing it.

Thanks!