Console.semdok

Add Sem to your website

A step-by-step guide to putting Sem, the voice assistant, on your website so it answers your visitors from your own website's content, and to keeping your keys safe.

Contents
  1. Before you start
  2. Know your keys: which are public, which are secret
  3. Create an assistant for your website
  4. Limit it to your own website
  5. Give it your website's content
  6. Set its character and instructions
  7. Add the code to your website
  8. Keep secret keys in a .env file
  9. Test it
  10. If a key is exposed
  11. Security checklist
  12. Troubleshooting

Before you start

Know your keys: which are public, which are secret

Console.semdok gives you three kinds of keys. Only one of them may ever appear in your web pages.

KeyLooks likeWhere it goesCan visitors see it?
Assistant key (public)sem_pub_live_…In your web page, inside the Sem embed codeYes, by design
Semdok API key (secret)sk-…Only on your server, in a .env fileNever
Sem API key (secret)sem_sk_…Only in the Sem app, Semdok Harness, or your server's .envNever
The assistant key is meant to be public. It only lets someone talk to your assistant. It cannot change your assistant's instructions, its knowledge or your account: those changes are only possible inside Console.semdok, after signing in with the emailed code. Still, anyone who copies it to another site would use your voice hours, so limit it to your own website (step 2).
Secret keys (sk-… and sem_sk_…) must never be in a web page, in JavaScript that runs in the browser, in a mobile app, or in a public code repository. Anyone who gets one can use it as you: spend your tokens and voice hours, and send their own instructions and questions in your name, so the answers can have nothing to do with your website and can be made to say whatever they want. Keep them in a .env file on your server (step 6).

1Create an assistant for your website

  1. Sign in to console.semdok.com and open SEM Assistant in the sidebar.
  2. Click New assistant and give it a name, for example "Acme website". Each assistant has its own key, character, allowed websites and knowledge, so you can have a different assistant for each of your websites.
  3. Under Assistant API key, you see its public key (sem_pub_live_…). You don't need to copy it yet: it is already inside the embed code in step 5.

2Limit it to your own website

  1. In the assistant's settings, find Allowed websites.
  2. Enter your website's addresses, separated by commas, for example:
    https://www.acme.com, https://acme.com, https://*.acme.com
  3. Click Save. This list tells Sem which websites your assistant belongs to, so a copied embed code can't use your assistant (or your voice hours) on someone else's site.
Don't leave it on * (any website) once your site is live. * is only for testing.
Being rolled out: Sem is starting to check this list on every visit. Until that check is switched on for your assistant, watch your voice usage, and if you see use you don't expect, follow If a key is exposed.

3Give it your website's content

  1. On the same page, under Assistant Knowledge Base, choose Fetch from a website.
  2. Enter your website's address and keep Also fetch linked pages of the same site ticked (up to 20 pages per website, up to 10 websites).
  3. Click Fetch content. When it shows ready, click View content to see exactly what Sem read.
  4. Use Try a question to check: ask something your website answers, such as "What are your opening hours?", and see the passage Sem finds.
  5. When your website changes, click Refresh next to it so Sem reads the new version.
Your content is only used by your own assistant, to look up answers for your visitors. It is not used to train any AI model.
Being rolled out: Sem on your website is being connected to this knowledge. Until that is switched on, Sem answers from its instructions (step 4), so put your most important facts (opening hours, contact details, prices) in the instructions too.

4Set its character and instructions

  1. In Character Customizer, choose the name, avatar, voice, theme and background, and write the greeting visitors hear first.
  2. In Instructions, tell Sem its job on your site, for example:
    You are Sem, the assistant on acme.com. Answer only from Acme's website content.
    If the answer isn't there, say you don't know and suggest contacting support@acme.com.
    Be brief and friendly. Never discuss competitors or give medical or legal advice.
  3. Click Save. The preview on the right shows how it looks.

5Add the code to your website

Copy the embed code from 1-line script tag for your website (the Copy Script button). It looks like this, with your own key:

<!-- Sem assistant -->
<script
  src="https://live.semdok.com/widget/sem-widget.js"
  data-assistant-brand="Acme website"
  data-assistant-avatar="female"
  data-assistant-theme="dark"
  data-assistant-api-key="sem_pub_live_xxxxxxxxxxxxxxxx"
  defer>
</script>

Paste it just before the closing </body> tag of every page where Sem should appear. A Sem button then appears in the corner of the page.

Optional settings

AttributeWhat it does
data-assistant-positionWhere the button sits, for example bottom-right or bottom-left
data-assistant-trigger-labelThe button's text, for example Ask Sem
data-assistant-greetingA greeting for this page only (otherwise the one from step 4)
data-auto-opentrue opens Sem when the page loads

On popular platforms

6Keep secret keys in a .env file

You only need a secret key if your own server also calls Semdok, for example to add an AI feature to your site through the Semdok API (https://console.semdok.com/v1). The website widget itself never needs one.

1. Put the key in a .env file on your server

# .env  (on your server only — never commit this file)
SEMDOK_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
SEMDOK_BASE_URL=https://console.semdok.com/v1

2. Keep the file out of your code repository

# .gitignore
.env
.env.*
!.env.example

Commit a .env.example with the variable names but no values, so others know what to set. On hosting platforms (Vercel, Netlify, Render, a VPS…), enter the key in the platform's Environment variables settings instead of a file.

3. Read it only in server code

Your browser code calls your server; your server adds the key and calls Semdok. The key never reaches the visitor.

// server.js (Node.js + Express)
import "dotenv/config";              // loads .env
import express from "express";
import rateLimit from "express-rate-limit";

const app = express();
app.use(express.json({ limit: "20kb" }));
app.use("/api/ask", rateLimit({ windowMs: 60_000, max: 20 }));   // stop abuse of your quota

app.post("/api/ask", async (req, res) => {
  const question = String(req.body?.question || "").slice(0, 1000);
  const r = await fetch(`${process.env.SEMDOK_BASE_URL}/chat/completions`, {
    method: "POST",
    headers: {
      "Authorization": `Bearer ${process.env.SEMDOK_API_KEY}`,   // the key stays on the server
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model: "auto/best-chat",
      messages: [
        { role: "system", content: "You are the assistant for acme.com. Answer only about Acme." },
        { role: "user", content: question }
      ]
    })
  });
  const data = await r.json();
  res.json({ answer: data.choices?.[0]?.message?.content ?? "" });   // never send the key back
});

app.listen(3000);
# Python (FastAPI) — same idea
import os, httpx
from dotenv import load_dotenv
load_dotenv()                                   # reads .env
KEY = os.environ["SEMDOK_API_KEY"]               # never hard-code it
Why this matters. If a secret key is exposed — pasted in a web page, shipped in a mobile app, pushed to GitHub, shared in a chat or a screenshot — anyone can use it as if they were you. They can spend your tokens and voice hours, and send their own instructions with your key, so the answers produced under your name no longer come from your website and can be made to say anything. Keeping the key in .env on your server, and only there, is what prevents this.

Test it

  1. Open your website in a normal browser window (over HTTPS) and click the Sem button.
  2. Allow the microphone when the browser asks.
  3. Ask something your website answers, and something it doesn't. Sem should answer the first from your content and, for the second, say it doesn't know (following your instructions).
  4. In Console.semdok, open Cost & Compute: Sem voice this month shows the voice hours used so far.
  5. View your page's source (right-click → View page source) and search for sk- and sem_sk_. Neither may appear anywhere.

If a key is exposed

  1. Revoke it straight away in Console.semdok: API Keys for sk-…, SEM Assistant → Sem API keys for sem_sk_…. A revoked key stops working at once.
  2. Create a new key and put it in your .env (or your host's environment variables), then restart your server.
  3. If an assistant key is being misused on another site, set Allowed websites (step 2). If you want a fresh key, create a new assistant and replace the embed code, then delete the old assistant.
  4. If the key was in a code repository, removing it from the latest version isn't enough — it stays in the history. Treat it as exposed and revoke it.
  5. Check your usage in Console.semdok and contact support@semdok.com if you see use you don't recognise.

Security checklist

Troubleshooting

What you seeWhat to do
No Sem button on the pageCheck the code is before </body> on that page and that the page was published. If your site has a Content Security Policy, allow Sem: script-src https://live.semdok.com; frame-src https://live.semdok.com
Sem doesn't hear youThe page must be HTTPS, and the visitor must allow the microphone (the browser's address-bar icon).
Sem doesn't know your contentIn SEM Assistant, check the website shows ready, use View content, and Refresh after changing your site. Make sure the embed code uses this assistant's key.
Sem stops working mid-monthYour plan's voice hours for the month are used up. They renew on your billing day, or upgrade in Subscriptions.
Works on your site but also on someone else'sSet Allowed websites (step 2).

Still stuck? Email support@semdok.com with your website address and the assistant's name. Never send us a secret key.