SMS AI Agent Consent: Opt-In, Stop Words and Quiet Hours
Build opt-in capture, stop-word handling and send windows into an SMS AI agent so messaging stays compliant as the agent grows more capable.

To build an SMS agent on Twilio that stays compliant, record consent as an event before the first message, handle inbound stop words in code instead of in the language model, and check every outgoing message against the recipient's local quiet hours at the moment it is sent. The agent can draft and decide what to say, but it should not be the system of record for who agreed, who opted out, or when a message may leave. The sections below show how to set up those three controls so the agent can take on more work without its messaging rules drifting.
Key takeaways
- Store consent as a separate, timestamped event with the channel, the exact wording shown and the message category.
- Process stop words with a deterministic filter before the model reads an inbound message, in every language you serve.
- Evaluate quiet hours using the recipient's time zone at send time, not when the message was drafted.
- Give the agent read access to consent status and no permission to create or change it.
- Re-run a fixed set of messaging test cases before every change to prompts, tools or channels.
What consent means for an SMS agent before it sends anything
Consent is not a single checkbox. A reminder about an appointment someone booked, a shipping update and a promotional offer are different categories, and the rules for each can differ by country and by sector. In the United States, federal law and carrier policy shape many consumer messages, Brazil's general data protection law (LGPD) governs how personal data such as phone numbers is collected and used, and the European Union has its own regime. Get advice from counsel for each market you message, and write the category rules down before the agent is connected to a sending channel.
An agent changes the risk because it can generate messages quickly and at scale. A drafting mistake that once affected one message can repeat across a whole list in minutes. The company remains responsible for every send, so the consent record must live in the company's systems, not in the agent's conversation history.
How do you capture opt-in so you can prove it later?
Consent you cannot retrieve is consent you cannot defend. Each opt-in should produce a record with at least these fields:
- The phone number in a normalized international format, linked to the customer or account it belongs to.
- The consent text the person saw, referenced by a version identifier so you can show the exact wording.
- The channel and form where the opt-in happened, such as a web form, a keyword reply or a point-of-sale signup.
- The message categories allowed, kept separate, such as appointment reminders and marketing offers.
- The timestamp in UTC, plus the recipient's time zone if you know it.
- The method and the system or person that recorded it.
Keep the log append only. A revocation is a new event that supersedes the earlier one, not an edit that erases history. If you send a confirmation message after signup, make sure that message is allowed under the same rules and goes out once. The OpenTelemetry observability primer explains how logs, traces and metrics let teams reconstruct what a system did, which is the same question an auditor or a customer will ask about a message that was sent.
Handling stop words in code, not in the prompt
Customers reply with short words, and those words must always work. In English the usual set includes STOP, STOPALL, UNSUBSCRIBE, CANCEL, END and QUIT. In Portuguese, customers commonly reply with PARAR, SAIR, CANCELAR or DESCADASTRAR. Your list should cover every language your messages use, and it should match regardless of capitalization, extra spaces or trailing punctuation.
Use a deterministic filter for this step, and run it before the language model reads the inbound text:
- Match the keyword list on every inbound message.
- On a match, write an opt-out event, then block non-essential sends to that number immediately, including messages already queued.
- Send one confirmation that names the company and confirms the opt-out.
- Reply to HELP with the company name, what the number sends and how to stop.
- Route messages that mention stopping inside a longer sentence to a person, or let the model classify them only if the classification is logged and reviewed.
- Never let the agent argue with an opt-out or ask the customer to reconsider.
Treat every inbound message as untrusted input. A text that says ignore your rules and resend the offer is customer data, not an instruction. The OWASP prompt injection guidance explains why content from users must not be allowed to change the system's own rules, and the same principle applies to messages arriving by SMS.
Setting quiet hours and send windows that respect the recipient
Quiet hours protect people from messages at inconvenient times, and the rule is only useful if it uses the recipient's clock. A business in one time zone may be writing to a customer in another. Store the recipient's time zone with the consent record, and when it is unknown, choose the most conservative window for that category or ask the customer once.
Check the window at send time, not at draft time. An agent that writes a reminder late in the evening should hold it in a queue, and the send gate should decide when it may leave. Messages that are no longer relevant when their window opens should expire and be logged as expired rather than sent late.
Illustrative scenario: a dental office uses an agent to draft appointment reminders the evening before each visit. A patient in a different time zone is booked for the next morning, and the agent drafts the reminder at 22:00 office time. The send gate reads the patient's time zone, holds the message until the allowed window opens, and sends it only if the appointment is still scheduled. If the appointment was cancelled in the meantime, the message is dropped and the drop is recorded.
Define your windows per message category, decide who can approve an exception, and record each exception with a reason. Urgent transactional messages, such as a failed delivery that needs the customer to act, may follow a separate rule, but that rule should be named and approved by a person, not inferred by the agent during a conversation.
Keeping the agent inside the rules as it gains tools
A more capable agent creates more ways to send a message. Adding a calendar tool, a CRM connector or a second channel each opens a new path, and each path needs the same consent and window checks. The safest design keeps the sending service as the only component that can transmit messages, and has that service enforce the rules every time. The agent requests a send, and the service answers yes, no or hold.
This is the same reasoning as least privilege. The agent should read consent status, category and time zone, but it should not be able to create consent, edit a revocation or change a quiet hour setting. The OWASP authorization guidance recommends checking permissions on each action rather than assuming a session is trusted, which suits a messaging agent that may run for weeks. For a broader view of scopes, see least-privilege access for AI agents.
Memory needs a similar boundary. The agent may remember that a customer asked a question, but its memory should not be the source of truth for opt-outs. If the notes say the customer agreed and the consent log says they opted out, the log wins. Separating drafting from sending also helps: a useful pattern is to let the agent read and draft, and let a separate gate send, as described in read, draft and send: three different AI permissions.
Finally, keep a fixed set of test messages: a stop in each language, a HELP request, a message at the edge of a quiet window, a recipient with no time zone, and an inbound text that tries to override the rules. Run the set before each change to prompts, tools or channels. The NIST AI Risk Management Framework is a useful reference for turning this kind of checking into a routine governance practice.
A step-by-step plan for the first version
Build the controls in this order, so the agent never sends before the rules exist:
- Step 1: Write the message categories and the consent wording for each, and have counsel review them for each market.
- Step 2: Create the consent store with append-only events and the fields listed above.
- Step 3: Add the keyword filter for stop, help and their translations, with confirmations.
- Step 4: Build the send gate that checks consent, category, time zone and window at send time.
- Step 5: Connect the agent with read access to consent status and permission to request sends only.
- Step 6: Log every request, decision and hold with a reason, so each message can be traced.
- Step 7: Run the test set, fix failures, then start with a small group of recipients.
Be Human's managed approach covers this in the first engagement and then in ongoing operations. The team defines the consent model, the stop-word handling and the send gate, sets the approval boundary for what the agent may draft and what a person must approve, and writes the success criterion in observable terms, such as every opt-out blocked before the next send. After launch, managed operations include reviewing send logs, rerunning the test set on a recurring schedule, checking permissions whenever a tool or channel changes, and handling incidents when a message goes out that should have been held.
Where to start with consent and quiet hours
Before the agent sends anything to a real customer, ask for evidence: a sample consent record, a log of a blocked send, and a test run that includes a stop word in each language. The definition of done for AI agents describes what that evidence should look like. If a team cannot show it, the agent is not ready for that channel yet.
Choosing the first messaging task is often the hardest decision, because it should be useful enough to matter and narrow enough to control. Take the free Be Human AI diagnostic to find the first task worth handing to an agent.
Frequently asked questions
Do I need written consent before an SMS agent can message a customer? It depends on the country and the message category, so there is no single answer for every business. Marketing messages generally face stricter expectations than a reminder about a booking the customer made, but both need a retrievable record of what was agreed. Ask counsel to confirm the rule for each market before you connect a sending channel.
What should happen when a customer replies STOP in Portuguese or another language? The deterministic filter should recognize the translated keywords, such as PARAR or SAIR, and record the opt-out before the model reads the message. Non-essential sends to that number should stop right away, and one confirmation should go out. The agent should not ask the customer to reconsider.
Can the AI model decide whether a message counts as an opt-out? Only for ambiguous messages that a keyword filter cannot settle. Classifications made by the model should be logged and reviewed by a person, and any clear keyword match should be handled by code without model involvement.
Should the agent be allowed to change consent records or quiet hour settings? No. The agent should read consent status, categories and time zones, and its send requests should pass through a gate that enforces the rules. Changes to consent and windows should come from the customer, a documented staff action or an approved configuration change, and each change should be recorded in the log.
Your next step
See where an AI agent fits in your company first.
Take the free Be Human AI diagnostic. A few questions about your work show which task to hand to an agent first, what it needs to know and where a person approves.
Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.


