How to handle edge cases in WhatsApp chatbot flows
Learn how to handle edge cases in WhatsApp chatbot flows — from off-topic questions to abusive messages — with graceful fallbacks and escalation rules.
Your WhatsApp bot will handle 80% of conversations smoothly. The remaining 20% — the edge cases — are where most bots fall apart. An unexpected question, an abusive message, an emoji-only reply, a customer writing in a different language — these are the moments that determine whether your bot feels robust or broken. This guide covers each major edge case and how to handle it gracefully.
TL;DR
- Edge cases are predictable, even when their content isn't. Build handling for the categories, not every specific instance.
- The fallback strategy wins by being honest. "I'm not sure — let me get someone to help" is always better than a wrong or confused response.
- Testing with strangers before launch is the most reliable way to surface edge cases you haven't thought of.
What counts as an edge case?
An edge case is any input your bot wasn't explicitly designed to handle. That sounds broad because it is — but edge cases fall into predictable categories.
The most common ones for WhatsApp bots:
- Unexpected or off-topic questions
- Ambiguous or unclear messages
- Abusive or hostile messages
- Questions the bot genuinely can't answer
- Very long messages
- Emoji-only or image-only messages
- Messages in a language the bot isn't configured for
- Multiple questions in a single message
Each category needs its own handling strategy. The good news is you don't need to anticipate every specific instance — just the category.
Off-topic questions
A customer messages your dental practice's WhatsApp bot asking for restaurant recommendations nearby. Or your bakery bot gets a message asking for advice on a home renovation.
Off-topic questions aren't hostile — they're just outside scope. Handle them with a friendly redirect:
"That's a bit outside my area — I'm mainly set up to help with [appointments/orders/etc.]. For that, [Google Maps / a quick search] would be your best bet. Is there anything I can help you with on the [business] side?"
This keeps the tone warm, acknowledges the question without being unhelpful, and gives a path forward. It also brings the conversation back on topic without being abrupt.
Add a short instruction to your system prompt: "If a customer asks about something unrelated to [business], acknowledge it briefly, suggest a general resource, and offer to help with something you can assist with."
Ambiguous or unclear messages
"Can you help me?" is ambiguous. "What about the other one?" without prior context is ambiguous. "Soon?" is ambiguous.
The right response to ambiguity is always a clarifying question — not a guess.
"Happy to help. Could you tell me a bit more about what you need? For example, are you looking to book something, check prices, or something else?"
Avoid guessing at what the customer meant and answering your guess. Even if you guess correctly 60% of the time, the 40% where you're wrong damages trust and creates a longer, more frustrating conversation.
Your system prompt should include: "If a message is unclear or lacks context, ask one clarifying question rather than guessing. Keep the clarifying question short and give two or three examples of what you can help with."
Abusive or hostile messages
Occasionally your bot will receive an abusive message — aggressive language, offensive content, or harassment. How it handles this reflects on your brand.
Build a three-part response into your system prompt:
- Acknowledge without engaging with the hostility
- Offer to help if there's a genuine issue underneath it
- Set a limit if the hostility continues
First response to hostility: "I can see you're frustrated. I genuinely want to help if I can — what's going on?"
If it continues: "I'm not able to continue this conversation in this direction. If you have a specific question or issue, I'm here to help — otherwise I'll need to leave it there for now."
You don't need to be confrontational. But you also don't need to absorb unlimited hostility. A firm, calm limit is appropriate and professional.
Questions the bot genuinely can't answer
This is the most common edge case and the most important to get right. When your bot doesn't know something, honesty is always the right call.
The failure mode here is hallucination — when the AI generates a confident-sounding but incorrect answer because it doesn't want to say "I don't know." This is far more damaging than admitting a limitation.
Your system prompt should have an explicit hard rule: "If you're not certain of an answer, never guess. Say: 'I don't have that information to hand — I don't want to give you the wrong answer. Here's how you can find out for sure: [contact method / website / phone number].'"
This is the most important prompt instruction you can write. An honest "I don't know" with a next step builds trust. A confident wrong answer destroys it.
Very long messages
Some customers will send a wall of text — a detailed complaint, a complex situation, multiple questions combined. AI models can handle long inputs, but very long messages require structured handling to ensure every part is addressed.
Instruct your bot: "If a customer sends a message with multiple questions or issues, acknowledge each one and address them in order. Use numbered points if there are three or more separate things to respond to."
Also set a practical limit on what the bot attempts to resolve alone: "If a message describes a complex situation with multiple issues, it's better to acknowledge it, ask one clarifying question to understand the most important issue, and offer to connect them to a team member who can give it proper attention."
Emoji-only messages
A customer sends "👍" or "😊" or "🙏." What does your bot do?
Most of these are positive acknowledgements — the customer is happy with a previous reply, or they're winding down the conversation. The right response is light and warm:
"Great 😊 Let me know if you need anything else."
You don't need a complex instruction for this one. Simply include in your system prompt: "If a customer sends only an emoji that seems positive, respond warmly and briefly, offering further help. If the emoji is ambiguous, ask if there's anything else you can help with."
For truly ambiguous emojis, a gentle "All good?" or "Anything else I can help with?" closes the loop without overthinking it.
Non-English messages
If your business operates in one language and a customer messages in another, you have a choice: respond in English and hope they can follow, respond in their language if possible, or acknowledge the gap and offer a human escalation.
For most small businesses, the pragmatic approach is: respond briefly in both languages if the AI can identify the language, then offer a human option.
"Hi — I'm best at helping in English, but I've flagged this for a team member who may be able to help in [language]. Alternatively, if you're able to message in English, I'm here."
If your business genuinely serves a multilingual audience, build explicit multi-language handling into your system prompt with specific instructions for each language you support.
How to test edge cases before going live
The most reliable testing method is strangers. Give your bot to five to ten people who didn't help build it. Tell them nothing about how it works. Ask them to message it naturally — including trying to break it.
People who didn't build your bot will naturally:
- Ask things you didn't anticipate
- Phrase questions in ways you wouldn't
- Send ambiguous or incomplete messages
- Test the limits of what the bot can do
Watch the conversations happen in real time if possible. Note every moment where the bot responded badly. After five people have tried it, you'll have a clear list of edge cases to fix.
Run the same process again after you've made updates. Two rounds of stranger testing before launch catches the vast majority of real-world failure modes.
Improving edge case handling through your system prompt
Every edge case you discover becomes a system prompt update. The format is consistent: describe the scenario, then prescribe the response.
"If a customer sends only an image with no text: acknowledge that you can't see the image, explain what you can help with, and ask if they can describe what they need in text."
"If a customer asks about a topic completely unrelated to [business]: [specific response]."
Over time, your system prompt becomes a living document that's been refined by real conversations. Bots that have been running for six months and actively maintained are dramatically better at edge cases than freshly launched bots.
CodeWords makes it easy to update your bot's system prompt through Cody, the AI automation assistant. Describe the edge case and the response you want, and Cody incorporates it into your prompt structure.