Skip to main content

Get started with the web channel

Overview​

The Moveo web channel enables you to add AI-powered conversations directly to your website. This channel provides a customizable chat interface that you can style to match your brand and configure to meet your specific requirements.

note

By default, a conversation in the web channel stays active for one hour if the user does not close the window. The web channel does not load if the user agent (browser) is a bot.

The user does not have to wait for the AI agent to finish an answer. If the user sends a text message while the AI agent is still answering, the AI agent stops that answer. Then it answers all of the new messages together in one reply.

Quick start​

To add the web channel to your website:

  1. Go to Deploy → Connections in your Moveo account
  2. Select your environment
  3. Select Connect on the Webchat integration
  4. Copy the generated snippet and add it before the </body> tag:
<script src="https://web.moveo.ai/web-client.min.js"></script>
<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
version: "v2",
})
.then((instance) => console.log("connected"))
.catch((error) => console.error(error));
</script>
  1. Add your domain to the trusted domains list
  2. Set the web channel state to Active

The web channel is now ready to receive messages.

Connect the web channel through the API or the MCP server​

Follow the quick start steps above. The console shows the snippet with your integrationId. For accounts in the United States and Brazil, the snippet also sets host.

Region hosts​

The snippet loads the same script in every region. The host option tells the web channel which region to connect to. Without host, it connects to Europe.

Regionhost value
Europehttps://channels-ws.moveo.ai (default)
United Stateshttps://channels-ws.us-central.moveo.ai
Brazilhttps://channels-ws.sa-east.moveo.ai
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
host: "https://channels-ws.us-central.moveo.ai",
});

Installation options​

Standard installation​

The standard installation loads the web channel on every page:

<script src="https://web.moveo.ai/web-client.min.js"></script>
<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
version: "v2",
})
.then((instance) => console.log("connected"))
.catch((error) => console.error(error));
</script>

Embed mode​

Render the chat within your page content instead of as a floating widget:

<div id="chat-container"></div>
<script src="https://web.moveo.ai/web-client.min.js"></script>
<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
element: document.getElementById("chat-container"),
version: "v2",
})
.then((instance) => console.log("embedded chat connected"))
.catch((error) => console.error(error));
</script>

Delayed initialization​

Wait for page load or user interaction before initializing:

<script src="https://web.moveo.ai/web-client.min.js"></script>
<script>
window.addEventListener("DOMContentLoaded", function () {
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
version: "v2",
})
.then((instance) => console.log("connected"))
.catch((error) => console.error(error));
});
</script>

User authentication​

Secure your web channel and authenticate users to ensure messages come from verified customers only.

Why authenticate?​

Authentication provides:

  • Security: Verify that messages come from your actual customers
  • Personalization: Pass user data securely to provide tailored responses
  • Privacy: Encrypt sensitive information end-to-end

Basic authentication setup​

  1. Generate RSA keys:
# Private key (keep secure on your server)
openssl genrsa -out private.pem 2048
# Public key (add to Moveo)
openssl rsa -in private.pem -outform PEM -pubout -out public.pem
  1. Add public key to Moveo:

    • Go to Deploy → Connections → Webchat → Advanced settings
    • Enable Activate end-to-end encryption
    • Paste your public key
  2. Generate JWT on your server:

const jwt = require('jsonwebtoken');

function generateToken(userId) {
const payload = {
sub: userId, // Required: unique user ID
iss: 'yourdomain.com', // Required: issuer
};

return jwt.sign(payload, process.env.PRIVATE_RSA_KEY, {
algorithm: 'RS256',
expiresIn: '5m', // Must expire within 24 hours
});
}
  1. Initialize with authentication:
<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
identityToken: "JWT_FROM_YOUR_SERVER",
version: "v2",
})
.then((instance) => console.log("authenticated"))
.catch((error) => console.error(error));
</script>

Keep the token fresh​

identityToken accepts a string or a function that returns a token or a promise with a token: string | (() => string | Promise<string>).

The web channel sends the token when it starts a session and each time it reconnects to that session. A reconnect follows a network drop, a page reload, or a second tab. An open connection does not need a new token.

With a string, the web channel sends the same token every time. When Moveo requires the token, it refuses a reconnect with a token after its exp. Then the string token must stay valid for the whole conversation. Moveo accepts an exp at most 24 hours ahead. After the exp, the web channel starts a new session with the same expired token, and Moveo refuses it too. The visitor sees an error screen until the page reloads with a new token, because Restart sends the same token again (see Authentication failures). With a function, the web channel calls it before each session start and each reconnect, and keeps no token between calls. Use a function when your tokens expire in less than one conversation. A function also makes a logout or an account switch take effect at the next reconnect, on a single-page app that does not reload.

<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
version: "v2",
identityToken: async () => {
const response = await fetch("/moveo-token", { credentials: "include" });
if (response.status === 401) {
return ""; // No user is logged in.
}
if (!response.ok) {
throw new Error(`Token endpoint: ${response.status}`);
}
const { token } = await response.json();
return token;
},
});
</script>

Your /moveo-token endpoint signs a token for the logged-in user, as generateToken does in step 3, and returns it as { "token": "<JWT>" }. Sign a new token on each call. With a function, an exp of five minutes is enough.

The function follows these rules:

  • If your page has no logged-in user, the function returns an empty string. The web channel then sends no token. If the token is optional, the visitor starts or rejoins the session without a verified identity. If Moveo requires the token, Moveo refuses the session, and the visitor sees an error screen with a Restart button.
  • A call fails if the function throws an error, returns no string, or does not answer in 10 seconds. Then the web channel calls it again after 1 second and after 2 more seconds. If every call fails, the result is the same as an empty string. If the token is optional, an outage of your token endpoint gives sessions without a verified identity. If every call times out, the chat waits about 33 seconds before it continues.
  • If your page loads a fixed version of the web channel script, update it before you pass a function.

Log out​

When the user logs out, call destroy(). For a full login and logout example, see User authentication flow.

Require an identity token​

By default, the identity token is optional, and a session ID is enough to reconnect to a session. You can make the token required for your integration. Then Moveo applies these rules:

  • The web channel cannot start a session without a valid token.
  • A reconnect to a session needs a valid token for the same user (sub) that started the session. Otherwise, the web channel starts a new session. That session also needs a valid token, so a missing or expired token gives an error screen.
  • A connection can send messages and read the history only for the session that it started or reconnected to.

To make the token required, set require_identity_token to true in the integration config with the update integration API. Your integration needs a public key in Activate end-to-end encryption. To turn it off, set it to false.

warning

Complete the checks below before you turn the setting on. A page that does not pass the token cannot start a chat. A page that loads an old web channel script loses the conversation on each reload. Moveo recommends that you ask Moveo support to turn the setting on with you.

Before you turn the setting on, complete these checks:

  1. Make sure that every page that loads the web channel passes identityToken, including the page of a mobile WebView.
  2. Make sure that every page loads the current web channel script.
  3. If your tokens expire in less than one conversation, pass a function.

A visitor without a valid token sees an error screen with a Restart button. For the small window, see Keep the chat when visitors leave.

Passing encrypted user data​

To securely pass sensitive user information (for example, account details, VIP status):

  1. Get Moveo's public key from your web integration settings
  2. Encrypt context with AES-256
  3. Encrypt AES key with RSA
  4. Include in JWT:
Match the encryption scheme exactly

Moveo decrypts encryption_key and init_vector with RSA-OAEP (SHA-256), and the context with AES-256-CBC. Libraries that default to a different padding or hash produce tokens Moveo cannot decrypt. In particular, node-rsa defaults to OAEP with SHA-1, so always set the OAEP hash to SHA-256, as the example shows.

const crypto = require("crypto");
const jwt = require("jsonwebtoken");

function generateSecureToken(userId, userContext) {
// Generate AES key and IV
const aesKey = crypto.randomBytes(32);
const iv = crypto.randomBytes(16);

// Encrypt context with AES-256-CBC
const cipher = crypto.createCipheriv("aes-256-cbc", aesKey, iv);
let encrypted = cipher.update(JSON.stringify(userContext), "utf8", "base64");
encrypted += cipher.final("base64");

// Encrypt the AES key and IV with Moveo's RSA public key.
// Moveo decrypts with RSA-OAEP / SHA-256, so the padding and hash must
// match exactly or decryption fails server-side.
const oaep = {
key: process.env.MOVEO_PUBLIC_KEY,
padding: crypto.constants.RSA_PKCS1_OAEP_PADDING,
oaepHash: "sha256",
};
const encryptedKey = crypto.publicEncrypt(oaep, aesKey).toString("base64");
const encryptedIV = crypto.publicEncrypt(oaep, iv).toString("base64");

// Create JWT with encrypted data
const payload = {
sub: userId,
iss: "yourdomain.com",
context: encrypted, // AES encrypted context
encryption_key: encryptedKey, // RSA encrypted AES key
init_vector: encryptedIV, // RSA encrypted IV
};

return jwt.sign(payload, process.env.PRIVATE_RSA_KEY, {
algorithm: "RS256",
expiresIn: "5m",
});
}

// Usage
const userContext = {
user: {
email: "user@example.com",
is_vip: true,
account_tier: "premium",
},
contract_id: "12345",
credit_limit: 10000,
};

const token = generateSecureToken("user-123", userContext);

The AI agent can use the encrypted context for personalization. Moveo never sends it back to the client, so sensitive data stays secure.

Authentication flow​

Content Security Policy​

If your site sends a Content-Security-Policy header, allow these hosts. Replace the channels-ws host with the host of your region.

DirectiveValueWhy
script-srchttps://web.moveo.aiThe script web-client.min.js.
frame-srchttps://web.moveo.aiThe web channel window loads in an iframe from this host.
connect-srchttps://channels-ws.moveo.ai and wss://channels-ws.moveo.aiThe configuration request and the WebSocket connection.
img-srchttps://res.cloudinary.comThe default avatar of the AI agent.

The snippet also has an inline <script> that calls MoveoAI.init. A policy that allows only hosts blocks this script, so the web channel does not start. To allow it, add a nonce: a random value that your server creates for each page response. Put the same value in script-src and in the nonce attribute of the inline script.

For example, for an account in Europe:

Content-Security-Policy: script-src 'self' https://web.moveo.ai 'nonce-RANDOM-VALUE';
frame-src https://web.moveo.ai;
connect-src 'self' https://channels-ws.moveo.ai wss://channels-ws.moveo.ai;
img-src 'self' https://res.cloudinary.com
<script src="https://web.moveo.ai/web-client.min.js"></script>
<script nonce="RANDOM-VALUE">
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
version: "v2",
});
</script>

If you cannot add a nonce, move the MoveoAI.init call to a script file on your own domain. 'self' in script-src allows that file.

If you set your own avatar or show files that users upload, also allow the hosts of these files in img-src and connect-src.

Security best practices​

  1. Keep private keys secure - Never expose them in client-side code
  2. Use short expiration times - Pass a function and set exp to five minutes. Moveo rejects JWT tokens that expire more than 24 hours ahead.
  3. Validate on server - Always generate tokens server-side
  4. Encrypt sensitive data - Use AES encryption for context data
  5. Trusted domains - Only allow your domains in settings
  6. HTTPS only - Always use secure connections

Mobile app integration​

To use the web channel in a mobile application:

  1. Host the web channel on a webpage accessible by URL
  2. Embed the webpage using a WebView or iframe:
<!-- Host this page on your server -->
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<script src="https://web.moveo.ai/web-client.min.js"></script>
<script>
MoveoAI.init({
integrationId: "YOUR-INTEGRATION-ID",
// Pass authentication from mobile app if needed
identityToken: window.AUTH_TOKEN,
version: "v2",
})
.then((instance) => {
// Expose instance to mobile app if needed
window.moveoInstance = instance;
})
.catch((error) => console.error(error));
</script>
</body>
</html>

Then embed this page in your mobile app's WebView component.

If the WebView stays open longer than the token's exp, pass a function that asks the app for a new token.

Next steps​