Skip to main content

Javascript interface

Javascript interface

Play

To play a video in the current scena banner, use the following code:

window.scena = window.scena || [];
window.scena.push({ type: "play" });

Pause

Similarly, you can pause the video with the following code:

window.scena = window.scena || [];
window.scena.push({ type: "pause" });

Open

It might be useful to change widget content as reaction to click on page's element. To switch scene from JavaScript, pass key-id value:

window.scena = window.scena || [];
window.scena.push({ type: "open", "key-id": "aaaaabbbbbb" });

Reference specific widget

If you have multiple video banners on a page and want to execute actions on a specific one, use the following code:

window.scena = window.scena || [];
window.scena.push({ type: "play", element: document.querySelector("scena-ai-banner[key-id=aaaaabbbbb]") });

Replace key-id "aaaaabbbbb" value with the ID of the banner you want to target.

Custom trigger module

To trigger a custom JavaScript event from your dialogue, add Custom Trigger module from the Extension Modules menu.

img/custom-trigger.png

Specify the name that you can use further in JavaScript code.

In your application code, listen to scena-trigger event to catch the event as it happens:

window.scena = window.scena || [];
window.scena.push({ type: "trigger", callback: function(name) {
console.log(name);
}});

e.name will contain value a of the specified scena.ai trigger name.