Skip to content

Embedded components playground

Pick a component, set its attributes, see it live in one of your sandboxes, and copy the code that places it in your page. The script is pinned to version 1.0.0with its integrity. Every attribute is explained in the embedded components guide.

Component

The element, what it shows and how it is placed: each attribute of the tag.

1 to 255 of A-Z a-z 0-9 : . _ -; on <lexopti-client> and <lexopti-case>, used without an id.
Show the header (header)Off: the screen hides its header and stepper (breadcrumbs, title card, status, step indicators, tab bar) and keeps its content. The pages show it by default (header="false" hides it); the classification hides it by default (header="true" shows the case's or the client's above the questionnaire).
Inside: the component clamps itself to its visible part while one is open, the dialog shows where the component is. Fullscreen: the component covers your page while one is open.
Empty: the component follows its content.
Parts to keep (features)
All checked: no attribute, every part your server kept in the session.

Appearance

Every colour, the corner radius, the text size and the font of the component: the live preview follows each move, and the code below shows exactly what you write. Each variable maps onto one of LexOpti’s design tokens.

Quick starts
Fonts your visitors already have: nothing is downloaded. A name they lack falls back to the generic family at the end of the stack.

What the partner writes

The same variables as the style attribute of the HTML below, as a stylesheet rule for every such element of your page; nothing for LexOpti’s own theme.

/* LexOpti’s own theme: nothing to write */

Live preview<lexopti-client>

Not connected: authorize a sandbox to see the component.

How the preview works

Authorize one of your sandboxes, as the API reference’s Test Request does: the page then asks POST /v1/embed-sessions for every session the component needs, as your server would, and shows the component with your sandbox’s data. The token stays in this page’s memory and is never stored; the portal’s application acts for sandbox organizations only. Without a sandbox, read the sandbox guide. In your own page, your server opens the sessions (step 4 of the guide) for an origin you register in the developer console.

Events received

    HTML

    <script
    	type="module"
    	src="https://embed.lexopti.com/embed/v1.0.0.js"
    	integrity="sha384-2N9mNdBzYHj8ZSUxBaHxKXNPRwcwlKcJQ7PopEKhcDnoKBmAJ8RVKFcn4FXAOWTZ"
    	crossorigin="anonymous"
    ></script>
    <lexopti-client
    	integration="YOUR_PUBLIC_ID"
    	client="LEXOPTI_CLIENT_ID"
    ></lexopti-client>
    <script type="module">
    	const element = document.querySelector("lexopti-client");
    	element.sessionProvider = async ({
    		codeChallenge,
    		codeChallengeMethod,
    		component,
    	}) => {
    		const response = await fetch("/your-server/lexopti-embed-session", {
    			body: JSON.stringify({ codeChallenge, codeChallengeMethod, component }),
    			headers: { "content-type": "application/json" },
    			method: "POST",
    		});
    		return { code: (await response.json()).code };
    	};
    	for (const type of ["ready","resize","navigate","client-created","case-created","check-started","check-completed","alert-reviewed","classification-validated","mention-created","session-ended","display-changed","error"]) {
    		element.addEventListener(`lexopti-${type}`, (event) => {
    			console.log(event.type, event.detail);
    		});
    	}
    </script>

    React

    With @lexopti/embed-react; the page still loads the script above.

    import { LexoptiClient } from "@lexopti/embed-react";
    import type { LexoptiSessionProvider } from "@lexopti/embed-react";
    
    const sessionProvider: LexoptiSessionProvider = async (request) => {
    	const response = await fetch("/your-server/lexopti-embed-session", {
    		body: JSON.stringify(request),
    		headers: { "content-type": "application/json" },
    		method: "POST",
    	});
    	return { code: (await response.json()).code };
    };
    
    const log = (type: string, detail: unknown) => console.log(type, detail);
    
    export function LexoptiEmbed() {
    	return (
    		<LexoptiClient
    			integration="YOUR_PUBLIC_ID"
    			client="LEXOPTI_CLIENT_ID"
    			sessionProvider={sessionProvider}
    			onReady={(event) => log(event.type, event.detail)}
    			onResize={(event) => log(event.type, event.detail)}
    			onNavigate={(event) => log(event.type, event.detail)}
    			onClientCreated={(event) => log(event.type, event.detail)}
    			onCaseCreated={(event) => log(event.type, event.detail)}
    			onCheckStarted={(event) => log(event.type, event.detail)}
    			onCheckCompleted={(event) => log(event.type, event.detail)}
    			onAlertReviewed={(event) => log(event.type, event.detail)}
    			onClassificationValidated={(event) => log(event.type, event.detail)}
    			onMentionCreated={(event) => log(event.type, event.detail)}
    			onSessionEnded={(event) => log(event.type, event.detail)}
    			onDisplayChanged={(event) => log(event.type, event.detail)}
    			onError={(event) => log(event.type, event.detail)}
    		/>
    	);
    }