Skip to content

API

In order to use the API you have to embed the rooomAssistant in an iframe in your website or app. The Javascript API is available if you import it via a script tag or if you prefer es6 modules you can import it directly.

You get the api files from the following url:

pure
https://assistant.rooom.com/api/rooom-assistant.js // as es6 module or...
https://assistant.rooom.com/api/rooom-assistant.iife.js // as iife

Here is an example of a html and javascript file that embeds the rooomAssistant and imports the API.

html
<!-- index.html -->
<html>
	<head>
		<title>My Digital Assistant</title>
	</head>
	<body>
		<iframe id="iframe" src=""></iframe>
		<script type="module" src="index.js"></script>
	</body>
</html>
js
// index.js

// url to the api file (as es6 module)
import { API } from 'https://assistant.rooom.com/api/rooom-assistant.js'

// get the iframe element
const iframe = document.querySelector('iframe') 

// create a new instance of the api with the iframe and the setup 
const api = new API(iframe, 'my-setup.json5') file

// wait for the api to be ready
api.ready().then(() => { 
    api.tts.speak('Hello World') // make the digital assistant speak
})