<ai12z-container> Web Control
Overview
The ai12z-container is a web component that embeds an ai12z-powered experience — such as a mortgage rate calculator, restaurant finder, product recommender, or any custom agent workflow — directly into your web page. Each container is identified by a key-name that maps to a configured custom integration, and an instance-id that uniquely identifies it when multiple containers appear on the same page.
You can place several containers side-by-side, each running a completely independent agent, and pass dynamic runtime parameters to any of them via JavaScript.
Setup
Add the following to the <head> of every page that uses the container control:
<script
type="module"
src="https://cdn.ai12z.net/pkg/ai12z@latest/dist/esm/library.js"
></script>
<link
rel="stylesheet"
href="https://cdn.ai12z.net/pkg/ai12z@latest/dist/library/library.css"
/>
You can then place one or more <ai12z-container> tags anywhere in your HTML.
Attributes
| Attribute | Required | Description | Example |
|---|---|---|---|
key-name | Yes | Identifies which agent / workflow to load. Must match a configured agent key in your ai12z portal. | key-name="LocalRestaurants" |
instance-id | Yes | A unique string that distinguishes this element when multiple containers exist on the same page. | instance-id="1234" |
data-key | Yes | Your agent API key. Can be set via HTML attribute or JavaScript. See Agent Settings for your key. | data-key="YOUR_API_KEY" |
data-mode | Yes | Runtime environment. Use dev for testing, prod (default) for production. | data-mode="dev" |
parameters | Optional | A JSON-stringified object of dynamic values passed to the agent at runtime (e.g., pre-fill form fields). | parameters='{"termYears":"15"}' |
Basic Usage
Single Container
<ai12z-container data-key="YOUR_API_KEY" key-name="LocalRestaurants" instance-id="1234">
</ai12z-container>
Multiple Containers Side-by-Side
Place independent containers in a flex layout — each loads its own agent and operates independently:
<div style="display:flex;">
<div style="width:50%;">
<ai12z-container data-key="YOUR_API_KEY" key-name="LocalRestaurants" instance-id="1234">
</ai12z-container>
</div>
<div style="width:50%;">
<ai12z-container data-key="YOUR_API_KEY" key-name="Mortgageratecalculator" instance-id="5678">
</ai12z-container>
</div>
</div>
Passing Parameters via JavaScript
Use setAttribute("parameters", JSON.stringify({...})) to pass dynamic data to a specific container instance after the page loads. Target the correct instance using the instance-id attribute selector.
<script>
document.addEventListener("DOMContentLoaded", function () {
const instance2 = document.querySelector('ai12z-container[instance-id="5678"]')
instance2.setAttribute("parameters", JSON.stringify({ termYears: "15" }))
})
</script>
This is useful when values come from user interactions, URL parameters, or other page state — such as pre-filling a mortgage calculator with a specific loan term.
Configure Attributes via JavaScript
All attributes can be set or updated dynamically in JavaScript after the component mounts:
<script>
document.addEventListener("DOMContentLoaded", function () {
const container = document.querySelector('ai12z-container[instance-id="1234"]')
container.setAttribute("data-key", "YOUR_API_KEY")
container.setAttribute("data-mode", "dev")
container.setAttribute("parameters", JSON.stringify({ city: "Austin" }))
})
</script>