zzzRespant
← All integration guidesIntegration guide

Add Respant to your Node.js / Express site

A Node.js backend almost never has one plain index.html sitting in a folder, your pages come from a template engine or a separate frontend build. Pick whichever matches your setup below, you only need to do this once.

Step by step

1

Option A: you use a template engine (EJS, Pug, Handlebars, Nunjucks)

Find the ONE shared layout file every page extends from, this is usually called layout.ejs, layout.pug, main.hbs, or a partial named footer/partials/footer.ejs, footer.pug, etc, and it typically lives in a views/ or templates/ folder at your project root (check wherever you called app.set("views", ...) in your Express app). Open it, find the closing </body> tag near the bottom, and paste your Respant embed snippet on its own line directly above it. Save, restart your server (or let nodemon reload it), and every page using that layout gets the widget.

2

Option B: Express serves a built frontend (React, Vue, Angular) via express.static

If your Express app just does app.use(express.static("public")) or similar to serve a built React/Vue/Angular app, don't edit the built file in public/ or dist/, it gets overwritten on every rebuild. Instead, open that frontend project's SOURCE root HTML file (public/index.html in Create React App, index.html at the project root in Vite, public/index.html in Vue CLI) and paste your snippet there before </body>, then rebuild (npm run build) so the change makes it into what Express actually serves.

3

Option C: Node.js is an API only, a separate frontend renders the pages

If your Node.js server only returns JSON (a REST or GraphQL API) and a completely separate frontend app (a different repo, a different framework, even a different host) renders the actual pages your visitors see, add the snippet to that frontend instead, Node.js itself has no HTML to paste into. Use whichever guide matches that frontend's own stack from the list below.

4

Restart and check your live site

Restart your Node.js process (or redeploy, if you host on something like Render, Railway, or a VPS with PM2), then open your live site in a browser, not localhost in a dev tool, and give it a few seconds to load.

Not sure which option is yours? Open your project's package.json, if you see "ejs", "pug", "hbs"/"express-handlebars", or "nunjucks" under dependencies, you're on Option A. If you see "react", "vue", or "@angular/core" alongside a build script, you're on Option B.

Your embed snippet

This is the exact line you paste. Your real snippet has your own chatbot's widget key filled in automatically, find it on your live preview screen right after you build your chatbot, or anytime from your dashboard under Website integration.

<script src="https://app.flenrok.com/flenrok-loader.js" data-respant-key="YOUR_WIDGET_KEY" async></script>

Don't type this by hand, copy it directly from your dashboard so the widget key matches your actual chatbot.

Test your widget

Open your live site in a normal browser tab, not a preview or editor view, and give the page a few seconds to fully load. Your chatbot's launcher should appear in the corner of the screen. Click it, type a real question a customer might ask, and check that the answer sounds right. If nothing shows up, clear your browser cache and reload, or double-check the snippet was saved in the right place and that you're looking at the published version of your site, not a draft.

Still stuck? Email us with your site URL and we'll take a look, or open the chatbot on the Respant site itself and ask it, it's trained to walk you through this exact step.

Haven't built your chatbot yet?

Build a working demo in minutes, free, no credit card. You'll get this exact snippet the moment it's ready.

Build My Demo Bot, Free