# Guardrails: protect your agent from spam and abuse > Protect your agent from abuse with a rate limit, spam detection and country blocking Guardrails are the QwryAI settings that protect your agent from abuse: a **Rate limit** that caps how fast visitors can send messages, **Spam detection** that pauses spam and abusive conversations, and **Country blocking** that hides your agent from visitors in the countries you choose. Guardrails are set per agent and apply mainly to your website channels (Chat bubble, Center Stage and Help Page), with some coverage of the API and messaging channels, as each section below lists. Go to **Build › Guardrails**. The page has two tabs: * **Auto protection** holds two cards, **Rate limit** and **Spam detection**. Each card has its own **Save** button, so save one before you edit the other. * **Blocklists** holds **Country blocking**. Guardrails settings take effect as soon as you save them; they don't wait for **Publish**. ![The Guardrails page on the Auto protection tab, with the Rate limit card above the Spam detection card, and the Blocklists tab beside it.](annotated/01-auto-protection.webp "Auto protection: Rate limit and Spam detection.") > [!NOTE] > > These Guardrails protect your agent from abuse. To set rules for your agent's replies, such as topics to avoid, use the **Guardrails** editor on **Build › Instructions** instead. See [Build](/docs/user-guides/chatbot/build). > [!TIP] > > You can also ask [Backstage](/docs/user-guides/chatbot/backstage) to change the rate limit, spam detection or country blocking for you, in plain language. ## Rate limit Use **Rate limit** to cap how many messages one visitor's device can send to your agent in a set time. Set **Limit to** *N* **messages every** *N* **seconds**, then write the **Message to show when limit is hit**. A visitor who goes over the limit sees this message instead of a reply until the time window passes. ![The Rate limit card with Limit to 20 messages every 240 seconds and the Message to show when limit is hit field.](annotated/02-rate-limit.webp "Limit to N messages every N seconds.") ### Defaults and allowed values | Setting | Default | Allowed values | | - | - | - | | **Limit to** (messages) | 20 | 1 to 200 | | **every** (seconds) | 240 | 1 to 3,600 | | **Message to show when limit is hit** | "Too many messages in a row" | Any text up to 500 characters | If a value is out of range, the card shows an error such as *Messages can't be more than 200.* or *Seconds can't be more than 3,600.*, and **Save** stays off until you fix it. ### Where the rate limit applies * **Applies to:** the Chat bubble and website iframe, for visitors on your website * **Doesn't apply to:** your own tests in the Playground ## Spam detection Use **Spam detection** to have QwryAI check visitor messages for spam. When a conversation is judged to be spam, it's paused and your agent stops replying to it. You can also pause a conversation yourself from [Inbox](/docs/user-guides/chatbot/activity). Turn on the switch in the card's header, review the definition, and select **Save**. ![The Spam detection card with its switch turned on and the What counts as spam for this agent field showing the default definition.](annotated/03-spam-detection.webp "Spam detection, with your own definition.") ### Defining what counts as spam **What counts as spam for this agent** holds the instructions the spam check follows, up to 2,000 characters. QwryAI starts you with a definition that flags: * **Profanity:** vulgar, obscene, insulting or sexually explicit words or slang, in any language. * **Spam:** unsolicited commercial promotions, scams, repetitive gibberish, random keyboard mashing, or emoji-only messages. Edit the text to suit your business. For example, relax the profanity rule for a casual brand, or add patterns you see often, such as competitor promotions or repeated links. Be specific about what should and shouldn't count, because anything the check judges to be spam pauses that conversation. You can't save with the switch on and the field empty. > [!TIP] > > Start with the default definition and adjust it after you've looked at paused conversations in [Inbox](/docs/user-guides/chatbot/activity). Too broad a definition can pause real customers who are simply frustrated. ### What happens when a conversation is paused * **The visitor** can keep sending messages. They're saved, but your agent doesn't reply. * **Your team** sees the paused conversation in **Inbox** and can pick it up or resume the agent. ### Resume a paused conversation **1. Open the conversation** Go to **Inbox** and open the paused conversation. **2. Resume the agent** Select **Resume AI** in the conversation header. Your agent replies to new messages again. ### Supported channels Spam detection works on: * **Chat bubble** and website iframe * **Center Stage** * **Help Page** * **API** * **WhatsApp, Messenger and Instagram** * **Android SDK and iOS SDK** Spam detection doesn't run on: * **Slack** * **Email**: email has its own spam filter. See [Email](/docs/user-guides/integrations/email). * **Zendesk Messaging** * **Phone** ## Country blocking Use **Country blocking** on the **Blocklists** tab to hide your agent from visitors in particular countries. QwryAI works out each visitor's country from their IP address. ### Blocking a country **1. Open Blocklists** Go to **Build › Guardrails** and open the **Blocklists** tab. **2. Pick the countries** Under **Blocked countries**, open **Select countries...** and search for a country by name. Select each country you want to block. Each one appears as a chip with its flag below the picker. ![The Country blocking card with the Blocked countries picker open, a Search countries box, Select all, and a list of countries with flags.](annotated/04-country-blocking.webp "Search, select, save.") **3. Save** Select **Save**. QwryAI confirms with *Country blocking settings saved.* To unblock a country, select the **X** on its chip and save again. ### Allowing only a few countries To make your agent available in only a few countries: 1. Select **Select all** in the country picker. 2. Unselect the countries you want to allow. 3. Select **Save**. The picker then shows how many countries are blocked. ### Supported channels * **Chat bubble** and **Center Stage**: not shown to visitors from blocked countries. * **Help Page**: not available to visitors from blocked countries. * **API**: chat requests from blocked countries are turned away. > [!NOTE] > > Country blocking doesn't apply to **WhatsApp, Messenger, Instagram, Slack, Zendesk, email, Phone or the Playground**. Conversations on these channels carry on as usual wherever the customer is. ## Frequently asked questions > [accordion] Why are several visitors hitting the rate limit at once? > > Check that **Limit to** isn't set too low for how your customers chat. Raise it, or lengthen the window, so a normal conversation fits. > [accordion] Does spam detection pause real customers? > > It can, if your definition is too broad. Read paused conversations in **Inbox**, select **Resume AI** for any that weren't spam, and tighten **What counts as spam for this agent**. > [accordion] Can I unpause a conversation that spam detection paused? > > Yes. Open it in **Inbox** and select **Resume AI**. Your agent then replies to new messages again. > [accordion] What does a paused visitor see? > > Nothing changes on their screen. Their messages are saved, but your agent doesn't reply until your team picks up the conversation or resumes the agent. > [accordion] Can I allow only certain countries? > > There's no allowlist, but you can get the same result: select **Select all** in the country picker, unselect the countries you want to allow, and save.