> For the complete documentation index, see [llms.txt](https://docs.aisuru.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aisuru.com/en/frontend/web-component.md).

# Web Component

### Overview

The Memori Web Component is a standard web component that can be embedded in any HTML page with no framework dependencies. It's the ideal solution for quick, straightforward integrations.

[🔗 GitHub Repository](https://github.com/memori-ai/memori-webcomponent)

#### Key Features

* Ready to use in plain HTML;
* No framework dependencies;
* Configuration via HTML attributes;
* Supported in all modern browsers;
* Automatic component lifecycle management.

### Installation <a href="#installazione_233" id="installazione_233"></a>

#### **CDN Installation**

```html
<!-- Import Web Component -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@memori.ai/memori-webcomponent/dist/memori-webcomponent.js">
</script>
<!-- Import styles -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@memori.ai/memori-react/dist/styles.min.css"
/>
```

#### **NPM Installation**

```batch
# npm
npm install @memori.ai/memori-webcomponent
# yarn
yarn add @memori.ai/memori-webcomponent
```

### Basic Usage <a href="#utilizzo_base_261" id="utilizzo_base_261"></a>

#### **Simple Implementation**

```html
<memori-client
  memoriName="MyMemori"
  ownerUserName="user"
  tenantID="your-tenant.com"
  apiURL="https://backend.memori.ai"
  baseURL="https://your-base-url.com"
  height="500px"
  multilingual="true"
></memori-client>
```

### Advanced Usage <a href="#utilizzo_avanzato_277" id="utilizzo_avanzato_277"></a>

#### **With Context Variables**

```html
<memori-client
  memoriName="MyMemori"
  ownerUserName="user"
  tenantID="your-tenant.com"
  context="LOCATION:Milan,USER_TYPE:premium,CUSTOM_VAR:value"
  height="100vh"
  showShare="true"
  showSettings="true"
  multilingual="true"
></memori-client>
```

#### **Get resource URL**

```javascript
const resourceUrl = await memori.asset.getResourceUrl({
  sessionId: sessionID,
  resourceName: "image.jpg",
});
```

#### Event Handling <a href="#gestione_eventi_303" id="gestione_eventi_303"></a>

```javascript
<script>
  // Listen for state changes
  document.addEventListener("MemoriNewDialogState", (e) = >{
    const state = e.detail;
    console.log("New dialog state:", state); < span class = "hljs-comment" > // Handle specific responses</span><span class="hljs-keyword">if</span> (state.emission?.includes(<span class="hljs-string">"product"</span>)) {  showProductDetails();}
  });
  // Handle end-of-speech events
  document.addEventListener("MemoriEndSpeak", () = >{
    console.log("Memori has finished speaking");
  });
  // Send a message
  function sendCustomButton() {
    window.typeMessage("Hello from the custom button!");
  }
  // Send a hidden message
  function sendHiddenCommand() {
    window.typeMessageHidden("system:update", true);
  }
</script>
<button onclick="sendCustomButton()">
  Send Message
</button>
```
