Sub topic 7
Turning questions into prompts without losing customer wording
This chapter assumes you have already scrubbed personal data, deduplicated the questions, labelled each with an intent, and grouped them into topic clusters. It also assumes you can read short Python scripts and know the record format from earlier chapters: id, text, source, intent, cluster and count. Here you turn those records into the prompts you will send to an AI assistant, and you keep the customer's own words while doing it.
Why wording is the whole point
A prompt is the exact text you submit to an assistant or AI search feature. Assistants are sensitive to phrasing. "Can I move my subscription to a different email address?" and "What is the procedure for modifying the contact email associated with a recurring plan?" mean the same thing to a person. They can retrieve different sources and produce different answers.
If you rewrite customer questions into tidy, formal language, you measure how an assistant answers your team's phrasing. Real customers will not have typed that phrasing. The aim of this step is to remove only what stops a question working as a standalone prompt, and to leave everything else alone.
What you may edit and what you must keep
Every edit moves the prompt away from the customer. Treat edits as a short, explicit list, not a matter of taste.
| Edit | Allowed? | Example |
|---|---|---|
| Remove greetings and sign-offs | Yes | "Hi team, how do I..." becomes "how do I..." |
| Split a message with several questions | Yes | One ticket becomes two prompts |
| Replace or drop personal-data placeholders | Yes, then review | "[EMAIL]" has no meaning to an assistant |
| Resolve references to the earlier thread | Yes, with care | "again" or "the above" needs context or removal |
| Fix spelling mistakes | Usually no | "cancle" may be how people really search |
| Change informal tone to formal | No | "my stuff won't sync" stays as written |
| Add your brand or product name | No | See the brand leakage pitfall later in this tutorial |
| Add detail the customer did not give | No | Do not invent plan names or error codes |
Spelling is a judgement call. Typos in search queries and chat messages are real, and assistants handle them differently. A good compromise is to keep the original in the main set and, if you want to study typo handling, add a separate labelled variant.
The path from record to prompt
Each prompt should be traceable to a real record, and each edit should be visible in the data. The flow below shows the order of operations.
Choosing the representative wording
A cluster holds many phrasings of one need. You need a rule for picking the main prompt, and it should not depend on whoever happens to be editing. A simple rule is to take the wording that appeared most often, break ties by choosing the shorter text, and break remaining ties alphabetically. The result is deterministic, so two people running the script get the same set.
Frequency is a good default because it favours the wording most customers use. A very short wording is a better tiebreaker than a long one because long tickets tend to contain extra context that the other questions in the cluster do not.
Group by cluster and intent together, not by cluster alone. A cluster such as billing can contain "how do I download my invoice" (how-to) and "why was I charged twice" (troubleshooting). Those are different prompts, and picking a single winner for the whole cluster would hide one of them.
The other wordings in the group are not wasted. Keep them as variant candidates. Paraphrases such as "move my subscription" versus "change the email on my subscription" are real differences in vocabulary, and a small number of them can be used as controlled variants of one prompt.
A working script
This script builds on the cleaning code from earlier chapters. It picks one representative per cluster-and-intent group, strips noise, splits multi-question messages, and flags anything that needs a human look. It runs as shown.
import re
GREETING = re.compile(r"^(?:hi|hello|hey)(?:\s+\w+){0,2}\s*[,!.]\s*", re.I)
SIGNOFF = re.compile(r"\s*(?:thanks|thank you|cheers)\b[^?]*$", re.I)
PLACEHOLDER = re.compile(r"\[(?:EMAIL|PHONE)\]")
THREAD_REF = re.compile(
r"\b(?:as i said|the above|my last (?:message|email)|earlier|again)\b", re.I
)
def strip_noise(text):
text = GREETING.sub("", text.strip())
text = SIGNOFF.sub("", text)
return text.strip()
def split_questions(text):
return [p.strip() for p in re.split(r"(?<=\?)\s+", text) if p.strip()]
def choose_representative(rows):
return min(rows, key=lambda r: (-r["count"], len(r["text"]), r["text"]))
def build_prompts(row):
parts = split_questions(strip_noise(row["text"]))
records = []
for i, part in enumerate(parts, start=1):
flags = []
if PLACEHOLDER.search(part):
flags.append("placeholder")
if THREAD_REF.search(part):
flags.append("needs_context")
if len(part.split()) < 4:
flags.append("too_short")
records.append({
"id": f"p-{row['id']}-{i}",
"text": part,
"source_id": row["id"],
"intent": row["intent"],
"cluster": row["cluster"],
"flags": flags,
})
return records
def prompts_for_groups(rows):
groups = {}
for row in rows:
groups.setdefault((row["cluster"], row["intent"]), []).append(row)
prompts = []
for group in groups.values():
prompts.extend(build_prompts(choose_representative(group)))
return prompts
if __name__ == "__main__":
rows = [
{"id": "q-0042", "text": "Can I move my subscription to a different email address?",
"intent": "how_to", "cluster": "account_management", "count": 37},
{"id": "q-0043", "text": "Hi team, how do I change the email on my subscription? Thanks!",
"intent": "how_to", "cluster": "account_management", "count": 12},
{"id": "q-0107", "text": "Why was I charged twice again? Please fix, my number is [PHONE].",
"intent": "troubleshooting", "cluster": "billing", "count": 9},
]
for p in prompts_for_groups(rows):
print(p["id"], p["flags"], p["text"])Running it prints:
p-q-0042-1 [] Can I move my subscription to a different email address?
p-q-0107-1 ['needs_context'] Why was I charged twice again?
p-q-0107-2 ['placeholder'] Please fix, my number is [PHONE].Three things happen here. The most frequent wording, q-0042, wins its group, and q-0043 is not used as a main prompt. The billing ticket is split into two pieces. Both pieces carry flags, so you can see that neither is ready to use yet.
The greeting regex only removes a greeting when punctuation follows within three words. "Hey can I move my subscription" is left alone, because stripping to the next punctuation would delete the actual question. The sign-off regex has the opposite risk: a sentence beginning "Thanks to the new update, why is..." loses the whole line only if no question mark follows, which is why the pattern refuses to match across a ?. Both patterns are blunt. Review a sample of their output on your own data before trusting them.
Resolving the flags
The flags mark the cases where code should stop and a person should decide.
placeholder: A prompt like "Please fix, my number is [PHONE]." has no question and no value for an assistant. Drop the piece. If the placeholder sits inside a real question, such as "Why did you email [EMAIL] twice?", rewrite it with a neutral phrase like "my email address" and record that you did.needs_context: "Why was I charged twice again?" depends on a history the assistant cannot see. Either remove the reference ("Why was I charged twice?") or drop the prompt. Removing it changes the question slightly, so mark it as edited.too_short: "Pricing?" is a real query, especially from search logs, but it is a weak chat prompt. Keep it if it comes from a source where people really type that, and label that source in the record.
Store the decision in the record, not only in your head. A field such as "edits": ["removed_thread_reference"] lets a later audit measure how far the set has drifted from the raw questions.
{"id":"p-q-0107-1","text":"Why was I charged twice?","source_id":"q-0107","intent":"troubleshooting","cluster":"billing","flags":[],"edits":["removed_thread_reference"]}Splitting multi-question messages
Support tickets often bundle questions: "Can I change my plan? Also, will I lose my data?" Sent as one prompt, the assistant may answer only one part, and you cannot tell which question each answer addresses. Splitting gives each question its own prompt, and the source_id field links them back to the same ticket.
Splitting has a cost. The second question may depend on the first ("will I lose my data?" only makes sense after "change my plan"). When pieces depend on one another, keep the message whole and mark it "multi_part": true, or rewrite the second piece so it stands alone. Do not split by default and hope for the best.
Controlled variants
Within one prompt, you can add a few variants that reflect real paraphrases from the same group. Keep these controlled:
- Take variants only from real wordings in the group, not from a model asked to paraphrase. Synthetic paraphrases tend to be fluent and uniform, which real questions are not.
- Cap the number, for example three per prompt, so that one popular topic does not take over the set.
- Give each variant the same
prompt_groupidentifier as the main prompt, so results can be reported per question and per wording.
Persona and context variants, such as "I'm a small business owner", are a separate step. Leave them out of this chapter's output, so you can tell wording effects apart from persona effects later.
Common errors
- Polishing as you go. Fixing grammar and capitalisation across the board feels harmless. It removes exactly the signal you collected the questions for. Make edits only from the allowed list.
- Choosing the best-written question as the representative. A well-written ticket is usually written by a more experienced customer. Choose by frequency, not by how pleasant the text is.
- Leaving ticket context in. Order numbers, product versions and agent names in the text make the prompt specific to one conversation. Check for them with a quick scan of the longest prompts.
- Losing the link to the source. Without
source_id, you cannot audit an edit or trace a weird answer back to the original question.
Checking your result
Before moving on, read a random sample of 20 prompts aloud. Each should sound like something a customer would type, stand alone without the ticket, and contain no brand name that the customer did not use. Anything that fails goes back through the flags above.
Exercise
A cluster contains three wordings: "cancel my plan" (count 40), "How can I cancel my subscription?" (count 40) and "I would like to terminate my membership, please advise" (count 5). Using the representative rule from this chapter, which wording becomes the main prompt, and where do the others go?
Show answer
The two count-40 wordings tie on frequency, so the tiebreak is shorter text. "cancel my plan" is shorter and becomes the main prompt. The other two are kept as variant candidates for the same prompt group. The formal wording, which only 5 customers used, should be among the first to be dropped if you apply the variant cap.
Exercise
The prompt "As I said earlier, why is my export still failing?" is flagged needs_context. Name two options for handling it, and say what you must record in either case.
Show answer
Option one: edit it into a standalone question such as "Why is my export failing?" by removing the thread reference. Option two: drop the prompt, because the question depends on information the assistant cannot see. If you edit, record the edit (for example removed_thread_reference) in the prompt's edits field, and keep the source_id so the original text can be found.