Integration Guide
Add MartesAI to your website in under 2 minutes. The Browser SDK is framework-agnostic — works with Next.js, React, Vue, WordPress, Shopify, and plain HTML.
Getting Started
MartesAI works by loading a small JavaScript SDK on your website. The SDK connects to the MartesAI runtime via WebSocket, observes live browser context, and renders the AI chat widget — no build step or framework dependency required.
Add script tag
Paste one line into your HTML or layout file.
Verify your domain
Confirm site ownership in the dashboard.
AI goes live
Visitors can chat, get tours, and convert.
The install snippet
You'll find your personalized snippet in the dashboard under Sites → Install. It looks like this:
<script
src="https://cdn.martesai.com/agent.js"
data-site-id="YOUR_SITE_ID"
data-runtime-url="wss://runtime.martesai.com/ws"
defer
></script>Next.js Integration
For Next.js apps, use the built-in next/script component with lazyOnload strategy. This ensures the SDK loads after your page is interactive, avoiding any hydration issues.
Step 1: Add environment variables
Create or update your .env.local file:
# .env.local
NEXT_PUBLIC_MARTESAI_SITE_ID=your_site_id_here
NEXT_PUBLIC_MARTESAI_RUNTIME_URL=wss://runtime.martesai.com/wsStep 2: Add the Script to your layout
In your app/layout.tsx (App Router) or pages/_app.tsx (Pages Router):
import Script from "next/script";
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
{children}
<Script
src="https://cdn.martesai.com/agent.js"
data-site-id={process.env.NEXT_PUBLIC_MARTESAI_SITE_ID}
data-runtime-url={process.env.NEXT_PUBLIC_MARTESAI_RUNTIME_URL}
strategy="lazyOnload"
/>
</body>
</html>
);
}Tip: The SDK mounts its UI under document.body, not document.documentElement. This avoids React/Next.js hydration mismatches — the widget is injected outside the React tree.
Step 3: Deploy
Deploy your Next.js app as usual. The SDK will load automatically on every page. Verify your domain in the MartesAI dashboard to activate the AI receptionist.
Vanilla HTML & Other Platforms
The SDK works on any website — WordPress, Shopify, Wix, Squarespace, or plain HTML. Just add the script tag before the closing </body> tag.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Website</title>
</head>
<body>
<!-- Your site content -->
<!-- MartesAI Browser SDK -->
<script
src="https://cdn.martesai.com/agent.js"
data-site-id="YOUR_SITE_ID"
data-runtime-url="wss://runtime.martesai.com/ws"
defer
></script>
</body>
</html>WordPress
Add the script via Appearance → Theme Editor → footer.php, or use a code insertion plugin like WPCode.
Shopify
Add the snippet in Online Store → Themes → Edit Code → theme.liquid, before the closing body tag.
Configuration
The SDK is configured entirely through HTML data attributes on the script tag. No JavaScript initialization is required.
data-site-idYesYour unique site identifier from the dashboard.
data-runtime-urlYesWebSocket URL for the MartesAI runtime (wss://).
srcYesURL to the SDK JavaScript file (agent.js).
Environment variables (Next.js)
# Required
NEXT_PUBLIC_MARTESAI_SITE_ID=your_site_id
NEXT_PUBLIC_MARTESAI_RUNTIME_URL=wss://runtime.martesai.com/ws
# Optional — CDN URL override (defaults to cdn.martesai.com)
NEXT_PUBLIC_MARTESAI_CDN_URL=https://cdn.martesai.com/agent.jsSecurity & Privacy
MartesAI is designed with privacy at the core. The SDK only observes page structure and visitor interactions — it never executes arbitrary JavaScript, mutates the DOM outside of safe scroll/navigate actions, or accesses sensitive form data.
- All actions are structured, typed tools validated by the runtime — no arbitrary code execution
- Data is encrypted in transit (TLS/WSS) and at rest
- The AI answers only from approved knowledge — it refuses off-topic questions
- No training on your content — your knowledge stays yours
- Domain verification ensures the SDK only runs on authorized sites
- Visitor sessions are isolated — no cross-site tracking
Ready to add MartesAI to your site?
Create a free account, add your site, and paste the snippet. It takes less than 2 minutes.
