We use cookies. Cookies and browser storage keep you signed in and remember your preferences. With your permission we also measure how the site is used. You can any time. See our cookie policy.

Chat widget

Chat widget code with private instructions: writing a system prompt that works

The embed code is the same for every chat widget. What makes yours useful is the private instruction behind it. Here is how to write one that keeps answers accurate and on brand.

Published:

Two chat widgets can share the same line of embed code and behave completely differently. The difference is the private instruction, often called a system prompt. It is stored on the server with your widget, sent with every conversation and never shown to visitors.

Where the instruction lives

Open a chat widget in Widgets and scroll to Behavior. The instruction field accepts up to 4,000 characters. Because it stays on the server, a visitor who inspects your page only sees the widget id in the script tag:

<script src="https://api14.com/widget.js" data-widget="YOUR_WIDGET_ID" async></script>

Changing the instruction takes effect on the next message. You never need to update the code on your site.

A structure that works

A good instruction answers four questions for the model.

  1. Who are you? "You are the assistant for Northwind, an online store for outdoor gear."
  2. What do you know? Paste the facts that matter: shipping times, return rules, opening hours, product lines. The model can only be as accurate as the facts you give it.
  3. What should you avoid? "Do not promise discounts. Do not give medical or legal advice. If you are not sure, say so and point to the contact page."
  4. How should you sound? "Answer in two or three short sentences. Use the visitor's language."

Keep each rule short and concrete. Long, vague paragraphs are harder for a model to follow than a short list.

Test it like a visitor

The editor preview sends real requests with your unsaved instruction, so you can iterate quickly:

  • Ask the five questions your support inbox sees most often.
  • Ask something your instruction does not cover and check that the widget admits it does not know.
  • Try to make it break a rule, for example by asking for a discount code.

Adjust the instruction after each round. Small wording changes often fix most problems.

Keep the brand consistent

The chat widget is white label: there is no logo and no "powered by" line. Set the title, greeting, placeholder, button label and error message in your own words, then match the accent color, corner radius and theme to your site. Texts you leave empty use defaults in your account language.

Pair the instruction with limits

An instruction shapes answers, but it is not a budget. Set a response length cap (maximum tokens) so answers stay short, and choose the API key the widget runs under. That key's daily spend limit and allowed models apply to every visitor request, which gives you a second, independent safety net.

Start with a draft on the widgets page, then fine tune it in your dashboard.