Log in

Keep your bot on topic with guardrails

Guardrails check every message against your rules before your bot replies. A message outside what your bot is for, about a topic you don't want it to handle, or trying to make the bot reveal or ignore its instructions gets a short refusal instead of an answer.

The check runs separately from the model that writes your bot's replies, so a message such as "ignore your instructions" can't talk its way past it. Your bot's instructions still matter: guardrails are an extra layer, not a replacement.

ℹ️

Pro and Enterprise

Guardrails are included on the Pro and Enterprise plans.

Who can do this: team owners and admins.

How rules work

Each rule is a reason to refuse a message. Before your bot replies, the message is checked against every rule that's switched on, and if any of them matches, the visitor gets a refusal instead of an answer. Rules don't depend on each other, so there's no order to think about.

RuleWhat it refuses
Off-topic messagesAnything that isn't about what you say the bot is for, such as "Questions about our products, orders, delivery and returns". Greetings, thanks, follow-up questions and asking for a person are never off-topic.
Keep instructions privateAttempts to get the bot to show, repeat or translate its instructions. On by default.
Block instruction overridesAttempts to change the bot's rules or role, such as "you are now in developer mode". On by default.
Suggested topicsTopics we've written and tested: writing or explaining code, medical advice, legal advice, financial or investment advice, competitors, politics and religion, and homework and creative writing.
Your own topicUp to 10 topics you describe yourself, such as "Anything about our competitors' prices".

Every rule has its own switch, so you can turn one off without losing it, and its own Test to check a message against that rule alone. Each rule also shows how many messages it refused in the last 7 days.

The Rules section of the Guardrails tab with Off-topic messages, the two built-in protections, a suggested topic and one of your own topics, each switched on with Test and Remove links

The rest of the tab:

SettingWhat it does
Refusal messageThe message your bot starts from when it refuses. It's adapted to the rule that matched and written in the visitor's language.
Refuse messages if the check can't runOff by default, so if the check is unavailable, messages go through as normal. Turn it on to refuse instead. Your bot then stops answering while the check is unavailable.

Steps

  1. Open your bot and go to the Guardrails tab.
  2. Under Rules, click Add rule and choose Off-topic messages. Say what the bot is for, for example "Questions about our products, orders, delivery and returns". It starts from your bot's description.
  3. Add any other rules from Add rule: a suggested topic, or Your own topic.
  4. Check that Keep instructions private and Block instruction overrides are switched on.
  5. Click Test on a rule to check a message against it alone, and adjust its wording until it catches what you want.
  6. Edit the Refusal message under Refusal if you want different wording.
  7. Before you turn guardrails on, run Test on past conversations (see below) and adjust your rules until it only catches messages you want refused.
  8. Turn on Check messages before the bot replies and click Save changes.

Test your rules before you turn them on

  • Test on a rule checks one message against that rule alone, as it is in the form, saved or not.
  • Try a message checks one message against every rule that's switched on, shows which one matched, and the refusal it would get. Add the previous turn to test follow-ups such as "now write that in Python".
  • Test on past conversations checks your bot's last 200 messages from the past 30 days against every rule that's switched on. It shows how many would have been blocked, answered or couldn't be checked, and how many each rule would have blocked. Each message is shown with what the bot had just said and the reply it actually gave, plus a link to the conversation. Click a total or a rule to see only those messages. Use it to spot real questions your rules would wrongly refuse. If you change your rules afterwards, run it again to see the difference.

Try a message showing a request for a Python script blocked as Off-topic, 95% sure, and the refusal the visitor would get

Test on past conversations results: 7 of 22 messages blocked, a bar for each rule, and blocked messages shown with the reply the bot actually gave

All three use message tokens, like live checks: a check costs about 150 to 300 message tokens, so testing 200 messages costs roughly 30,000 to 60,000. Long messages cost more, because they're checked in parts.

What visitors see

A refused message gets a refusal in place of an answer, such as "Sorry, I can't help with writing code, but I can help with your orders and deliveries." Visitors don't see that a guardrail was involved. Refusals for the built-in protections never say what was detected.

The refused message stays in the conversation transcript, but the bot ignores it when it answers later messages. On Slack and Discord, the bot reads earlier messages in the thread or channel as they are there, so a refused message can still be part of what it sees.

See what was refused

  • In Conversations, a refused message has a Blocked badge saying why, and the reply is marked Refusal from guardrails.
  • In the Conversations filters, turn on Blocked by guardrails to list only those conversations.
  • The Guardrails tab shows how many messages were refused in the last 7 days, in total and by each rule.

Where guardrails apply

Guardrails check messages on your website chat, the Chat Thing test chat, the API, the MCP channel, Slack, Discord, Telegram and WhatsApp, and in bot tests.

They don't check:

  • Voice calls, because the voice assistant answers some questions itself.
  • Email, or replies drafted in the support inbox, which a person reviews.
  • Scheduled tasks, because a task's goal is your own instruction, not a visitor's message.
  • Images and files. Only a message's text is checked. With Refuse messages if the check can't run on, a message that's only an image or a file is refused.

Costs

Each checked message uses about 150 message tokens with a few rules on, and about 300 with every rule on. A long message is checked in parts of about 4,000 characters, so a message of several thousand characters can use about 1,000. With guardrails on, a message over 16,000 characters gets the same "message too long" error as a message length limit. A refused message uses a few hundred more to write the refusal, which is still far fewer than a normal reply. So replies aren't slowed down, the bot starts searching your data sources while the check runs, so a refused message can also use the tokens for that search. See message tokens.

Troubleshooting

My bot refuses questions it should answer

Run Try a message with the question to see which rule refused it, or Test on past conversations and click a rule to see everything it caught. If Off-topic messages refused it, broaden what you say the bot is for. If one of your own topics caught it, reword it so it describes what you don't want the bot to do, such as "Giving medical advice" rather than "Health". You can also switch the rule off while you work on it.

Off-topic messages still get answered

Add the subject as Your own topic, or add Off-topic messages so that anything outside what the bot is for is refused. Very short or ambiguous messages are let through on purpose, so real questions aren't refused.

  • Write your bot's instructions

    Write the prompt that sets your bot's role, topics, tone, answer length, language, power-up use and handoff, with before-and-after examples.

  • Improve your bot's answers

    Fix a bot that says "I don't know", gives wrong or made-up answers, goes off-topic, rambles, forgets context or replies in the wrong language.

  • Message tokens and what happens when you run out

    What message tokens are, how each message is counted, how model multipliers work, when tokens reset, and what happens when your team runs out.

Last updated