<ai12z-form> Web Control
Overview
The ai12z-form is a web component that renders an AI-powered form — such as a hotel reservation, contact form, support request, or any custom form workflow — directly on your web page. Each form is identified by a key-name that maps to a form configured in your ai12z portal. You can embed multiple independent forms on the same page side-by-side. See Agent Settings API Key to get your API key.
Setup
Add the following to the <head> of every page that uses the form 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-form> tags anywhere in your HTML.
Attributes
<ai12z-form data-key="YOUR_API_KEY" key-name="<FORM_KEY_NAME>"></ai12z-form>
| Attribute | Required | Description | Example | Default |
|---|---|---|---|---|
key-name | Yes | Identifies which form to load. Must match a form key configured in your ai12z portal. | key-name="Hotel_Reservation" | |
data-key | Yes | Your agent API key from ai12z Agent settings. Can be set via HTML attribute or JavaScript. | data-key="YOUR_API_KEY" | |
data-mode | Yes | Runtime environment. Use dev for testing, prod for production. | data-mode="dev" | prod |
Basic Usage
Single Form
<ai12z-form data-key="YOUR_API_KEY" key-name="Hotel_Reservation"></ai12z-form>
Multiple Forms Side-by-Side
Place independent forms in a flex layout — each loads its own form configuration and operates independently:
<div style="display: flex; flex-direction: row;">
<div style="width:50%">
<ai12z-form data-key="YOUR_API_KEY" key-name="Hotel_Reservation">
<!-- Optional: custom privacy policy slot -->
<!-- <div slot="custom-privacy">Click here to view the privacy policy</div> -->
</ai12z-form>
</div>
<div style="width:50%">
<ai12z-form data-key="YOUR_API_KEY" key-name="Contact_Us"></ai12z-form>
</div>
</div>
Configure Attributes via JavaScript
All attributes can be set or updated dynamically after the component mounts:
<script>
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("ai12z-form")
form.setAttribute("data-key", "YOUR_API_KEY")
form.setAttribute("data-mode", "dev")
})
</script>
Complete Example
The example below renders two forms side-by-side: a hotel reservation form on the left and a contact form on the right.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ai12z Form Control</title>
<!-- ai12z web components -->
<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"
/>
</head>
<body>
<div style="display: flex; flex-direction: row;">
<div style="width:50%">
<ai12z-form key-name="Hotel_Reservation">
<!-- <div slot="custom-privacy">Click here to view the privacy policy</div> -->
</ai12z-form>
</div>
<div style="width:50%">
<ai12z-form key-name="Contact_Us"></ai12z-form>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", function () {
const form = document.querySelector("ai12z-form")
form.setAttribute("data-key", "YOUR_API_KEY")
})
</script>
</body>
</html>
Use Cases
| Scenario | key-name value |
|---|---|
| Hotel reservation | Hotel_Reservation |
| Contact / enquiry form | Contact_Us |
| Support ticket | Support_Request |
| Lead generation | Lead_Capture |
| Event registration | Event_Registration |
Troubleshooting
Form Does Not Render
- Verify
key-nameexactly matches the form key configured in your ai12z portal (case-sensitive). - Confirm the CDN script and stylesheet are loaded in
<head>before the<ai12z-form>tag. - Check the browser console for network or JavaScript errors.
Multiple Forms on the Same Page
- Each
<ai12z-form>operates independently based on itskey-name. - To target a specific form instance with
querySelector, use the attribute selector:document.querySelector('ai12z-form[key-name="Hotel_Reservation"]').
Related Documentation
- Forms — Create and manage forms in the ai12z portal
- Agent Settings — Obtain your API key
- Knowledge Box Control — Embed AI answers inline with search results
- Container Control — Embed any agent experience on your page