← Blog

How to Embed 3D On-Chain Agents on Your Site

This guide walks through embedding a three.ws 3D agent on any website — from creating the agent to dropping the <agent-3d> snippet into your HTML and configuring the page integration.

Step 1 — Create your agent in Widget Studio

Go to three.ws/widget-studio and create an agent. You'll configure:

Add your domain to allowed origins before going live. Without it, the action bridge is blocked by CORS and the agent can't communicate with your page.

Step 2 — Copy the embed snippet

After saving, the Studio gives you an embed snippet that looks like this:

<script src="https://three.ws/agent.js"></script>
<agent-3d agent-id="your-agent-id"></agent-3d>

That's the minimum. The script registers the custom element and the tag renders the agent. Add it anywhere in your HTML — the agent loads asynchronously and won't block the rest of your page.

Step 3 — Place the tag

The <agent-3d> element behaves like any inline block element. By default it renders at a sensible size in the flow of your page. Common placements:

Fixed corner widget (most common)

<style>
  agent-3d {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 280px;
    height: 400px;
    z-index: 999;
  }
</style>
<agent-3d agent-id="your-agent-id"></agent-3d>

Inline in a section

<section class="hero">
  <div class="hero-copy">
    <h1>Your headline</h1>
    <p>Your description</p>
  </div>
  <agent-3d agent-id="your-agent-id" style="width:360px;height:520px;"></agent-3d>
</section>

Step 4 — Wire page events (optional)

The agent can receive events from your page and send events back. Use the postMessage action bridge:

Send an event to the agent

const agent = document.querySelector('agent-3d');
agent.postMessage({ type: 'event', name: 'cart-updated', data: { items: 3 } });

Listen for events from the agent

window.addEventListener('message', (e) => {
  if (e.data?.source === 'agent-3d') {
    console.log('Agent event:', e.data);
  }
});

Set emotion or animation from JavaScript

agent.postMessage({ type: 'set-emotion', emotion: 'excited' });
agent.postMessage({ type: 'play-animation', clip: 'wave' });

Step 5 — Configure mode and size

The <agent-3d> element accepts attributes for common configuration without JavaScript:

<agent-3d
  agent-id="your-agent-id"
  mode="minimal"
  theme="dark"
  start-open="false"
></agent-3d>

Common issues

Links


← All posts