Install the live chat widget on Spring Boot
XACUBE puts a live chat widget on your Spring Boot site, so your live agents can answer visitors the moment they ask, from one shared inbox. The free plan covers one agent.
- Open
src/main/resources/templates/layout.htmland paste the code just before</body>. - Publish your site. The chat appears on every page.
<script src="https://chat.xacube.chat/w.js" data-key="YOUR_PUBLIC_KEY" async></script>
Replace YOUR_PUBLIC_KEY with your own key. In your panel, open your website and this code is shown with your key already in it.
Recognise signed-in customers
// In your controller:
Mac mac = Mac.getInstance("HmacSHA256");
mac.init(new SecretKeySpec(secret.getBytes(UTF_8), "HmacSHA256"));
model.addAttribute("xacubeHash", HexFormat.of().formatHex(mac.doFinal(userId.getBytes(UTF_8))));
<!-- Thymeleaf -->
<script src="https://chat.xacube.chat/w.js" data-key="YOUR_PUBLIC_KEY"
th:attr="data-user-id=${user.id}, data-user-hash=${xacubeHash}, data-user-name=${user.name}, data-user-email=${user.email}" async></script>