Skip to main content
Create my assistant

Install LIRAA on your site

The code of each creation is copied from Mini Studio, at the Go live step. Here is where to place it with your tool, and how a developer can drive LIRAA.

HTML site

Paste the code just before </body>. The bar and the embedded module appear where their element is.

React and Next.js

Load the script once, then place the element. LIRAA follows page changes by itself.

<Script src="https://embed.liraa.app/lira.js" strategy="afterInteractive" />
<lira-surface surface="embed" token="CODE" product={sku} />

Vue and Nuxt

Declare lira-surface as a custom element, so that Vue does not look for a component.

// vite.config
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'lira-surface' } } })

// nuxt.config
export default defineNuxtConfig({ vue: { compilerOptions: { isCustomElement: (tag) => tag === 'lira-surface' } } })

<lira-surface surface="embed" token="CODE" :product="sku" />

Angular

Add CUSTOM_ELEMENTS_SCHEMA to the component holding the element.

@Component({ schemas: [CUSTOM_ELEMENTS_SCHEMA], template: '<lira-surface surface="embed" token="CODE" [attr.product]="sku"></lira-surface>' })

Webflow, Wix and Squarespace

In the site’s custom code, footer part, for the Widget; an embedded code element where you want the bar or the module. Adding code may depend on your subscription to these tools.

WordPress and WooCommerce

In a code snippet or your child theme, before </body>. Clear your cache plugin after installing. So that the assistant knows which product is shown, add data-lira-product with the reference in the product template. LIRAA also reads your public catalogue: enter the shop’s address in Mini Studio.

Shopify

In Shopify: Online Store, Themes, then “Edit code” on the published theme; paste the code into theme.liquid, just before </body>. LIRAA also reads your public catalogue: enter the shop’s address in Mini Studio. A Shopify app that avoids touching the theme’s code is in preparation.

Say which product is shown

Context informs the assistant. It is never proof of identity and gives access to nothing private.

<main data-lira-product="P001" data-lira-category="Jackets">…</main>

Drive LIRAA from your code

mount returns a handle: its calls wait for the surface to be ready. The embedded module has no open or close: it is always open. setTheme changes the bar and the Widget’s button; the inside of the Widget and of the embedded module keep the theme put online.

const widget = window.LIRAA.mount({ surface: 'widget', token: 'CODE' });
widget.open();
widget.close();
widget.updateContext({ productId: 'P001', pageType: 'product' });
widget.unmount();

const searchBar = window.LIRAA.mount({ surface: 'fastbar', token: 'CODE', container: '#search' });
searchBar.search('black jacket');

window.LIRAA.setLocale('en');
window.LIRAA.setTheme({ primaryColor: '#00aa77' });
window.LIRAA.signal('error');
window.LIRAA.destroy();

Listen to what happens

Nothing written in a conversation goes through these events.

const stop = window.LIRAA.subscribeEvent('search_result_clicked', (event) => {
  console.log(event.position, event.results);
});
// surface_loaded, surface_opened, surface_closed, surface_displayed,
// search_submitted, search_results_shown, search_result_clicked, search_term_clicked,
// action_requested, action_succeeded, action_failed, contact_requested, fatal_error

Keep a creation for signed-in customers

Create the key in Go live, Advanced mode, and keep it on your server. It signs who is signed in; the page passes it on; LIRAA checks it. This decides what shows and opens nothing private. A proof lasts 24 hours at most.

// On your server, never in the browser (Node.js)
const exp = Math.floor(Date.now() / 1000) + 3600;
const signature = createHmac('sha256', LIRA_IDENTITY_KEY).update(user.id + '.' + exp).digest('hex');

// In the page, before the code of LIRAA
window.__liraIdentity = { id: user.id, exp, signature };

// Or later, when the visitor signs in or out
window.LIRAA.identify({ id: user.id, exp, signature });
window.LIRAA.identify(null);

Consent

By default, LIRAA counts loads and openings, with no cookie or personal data. To wait for your consent tool, set the flag before the script. A refusal, or the browser’s Global Privacy Control signal, stops these measures; the surfaces keep working. Consent given after loading applies from the next pages in the Widget and the embedded module.

<script>window.__liraConsent = false;</script>
<!-- LIRAA’s code -->

window.LIRAA.setConsent(true);

Your site’s security policy

If your site uses a CSP, allow LIRAA’s addresses. The bar and the Widget’s button set their own styles: style-src must accept them.

script-src https://widget.liraa.app https://embed.liraa.app https://fastbar.liraa.app;
connect-src https://widget.liraa.app https://embed.liraa.app https://fastbar.liraa.app;
frame-src https://widget.liraa.app https://embed.liraa.app;
style-src 'unsafe-inline';
img-src https: data:;

A platform not in this list has not been tested: try it on a test page before announcing it to your customers. These guides are written from what was checked on HTML and React sites.