AskMavis
HelpChangelogRoadmapFeedback
  • Getting started
  • Your AI agent
  • Actions and procedures
  • Install your agent
    • Add the messenger to your website
    • Share a chat page link
    • Sign in your visitors (identity verification)
    • Add your agent to a Next.js site on Vercel
  • Helpdesk
  • Contacts
  • Help center and boards
  • Workspace and account
  • FAQ
Install your agent

Add your agent to a Next.js site on Vercel

Load the messenger in a Next.js or Vercel project using an environment variable.

AT
Written by AskMavis Team
Published 42m ago

If your site is a Next.js project on Vercel, you can keep your agent's ID in an environment variable instead of in your code.

1. Allow your website

Open your agent, go to Guardrails and add your site under Allowed domains, for example https://your-project.vercel.app and your own domain. Then enable the widget on the Install tab.

2. Add the agent ID

  1. Copy the Agent ID from Agent settings.
  2. In your Vercel project, open Settings > Environment Variables.
  3. Add NEXT_PUBLIC_ASKMAVIS_AGENT_ID with the Agent ID as its value.

3. Load the messenger

Add this to app/layout.tsx, inside <body>. For src, use the address of messenger.js shown in the snippet on your agent's Install tab.

import Script from 'next/script';

const agentId = process.env.NEXT_PUBLIC_ASKMAVIS_AGENT_ID;

// In app/layout.tsx, inside <body>:
{agentId ? (
  <Script
    src="https://mavis.help/messenger.js"
    data-messenger-config-id={agentId}
    data-consent="granted"
    referrerPolicy="strict-origin-when-cross-origin"
    strategy="afterInteractive"
  />
) : null}

Then redeploy your project.

Related

  • Add the messenger to your website

Was this article helpful?

Contact support

Related articles

  • Add the messenger to your websitePaste one snippet to put your AI agent on any website, with steps for popular site builders.
  • Share a chat page linkGive your AI agent its own page, with the chat already open, to share in emails, social profiles or a QR code.
  • Sign in your visitors (identity verification)Let your agent recognise signed-in customers securely, so nobody can pretend to be someone else.
← Back to Help Center

On this page

  • 1. Allow your website
  • 2. Add the agent ID
  • 3. Load the messenger
  • Related
Powered by AskMavis