Sub topic 4
Preparing Knowledge articles for retrieval
What this chapter assumes
You should know basic Salesforce administration: objects, fields, and permission sets. You should also have seen Knowledge articles in Lightning Experience, and you should know what an Agentforce agent is. This chapter covers the source side of grounding. Whatever you do or skip here determines what a retriever can find later, because a retriever can only return what was ingested, and ingestion only sees what was published.
Why article quality sets the ceiling
A retriever does not read articles the way a person does. Later chapters cover how content is split into chunks and turned into vectors. For now, remember one point: each chunk is matched to a question on its own, so the chunk must make sense without the rest of the article around it.
Three properties of your articles decide retrieval quality:
- Status. Only published content is a candidate for retrieval.
- Self-contained text. Each section should name its subject and state its answer.
- Clean structure. Headings, short paragraphs, and plain text chunk better than long blocks or content that lives in images.
Fixing these in Knowledge is cheaper than compensating for them with prompts or retriever settings.
How Knowledge stores articles
Lightning Knowledge stores articles in a Knowledge object, with the API name Knowledge__kav by default. Each row is one article version. An article that has been edited several times has several rows, and each row has a publication status.
| Field | What it tells you |
|---|---|
| `Id` | The ID of this specific version |
| `KnowledgeArticleId` | The ID shared by all versions of one article |
| `Title` | The article title, which is often the strongest signal for matching |
| `UrlName` | The URL-friendly name |
| `PublishStatus` | `Draft`, `Online`, or `Archived` |
| `Language` | The language of this version, such as `en_US` |
| `LastPublishedDate` | When this version was last published |
Your org may use a different record type or extra rich text fields. Your admin defines which fields hold the answer text, such as a Summary, Question__c, or Answer__c. Check your own object definition before you plan ingestion.
Version states
An article version moves through a small set of states. Only the Online version is the live one.
When you edit an online article, Salesforce creates a draft version. The old online version stays live until you publish the new one. This matters for freshness: a correction sitting in draft does not reach the agent.
Check what is available to ingest
Before you build anything in Data Cloud, confirm what is published. Run this query in Developer Console or Workbench.
SELECT Id, Title, UrlName, PublishStatus, Language, LastPublishedDate
FROM Knowledge__kav
WHERE PublishStatus = 'Online'
AND Language = 'en_US'
ORDER BY LastPublishedDate DESC
LIMIT 20The query lists the 20 most recently published English versions. Use it to answer three questions:
- Is the article you expect in the list?
- Is
LastPublishedDatenewer than your last ingestion refresh? - Is the
Languagethe one your customers use?
If an article is missing here, nothing downstream can fix that. Publish it first.
Write articles for chunking
Content gets split before it is indexed. You do not control the exact split points from within the article, but you can write content that survives splitting.
Make each section answer one question
A chunk that says "It expires after 30 days" is useless once it is separated from the paragraph that said what "it" is. Compare two versions of the same fact:
| Weak | Stronger |
|---|---|
| "It expires after 30 days. Renew it before then." | "A trial license expires after 30 days. Renew the trial license before it expires." |
The stronger version repeats the noun. That reads slightly stiffly to a human and works much better for retrieval.
Use headings that carry the topic
Use headings that match how customers phrase the problem, such as "Reset a password for a locked account". A heading like "Overview" tells the retriever nothing. Where your ingestion setup keeps heading structure, it gives each chunk its context.
Keep the answer in text
Content in images, attached PDFs, or embedded videos may not reach the index, depending on what you ingest. If a diagram holds the only statement of a rule, write the rule in text as well.
Avoid duplicates and contradictions
If three articles describe the same return policy with different numbers, the retriever may return any of them, and the model will have to pick one or blend them. Retire outdated articles and consolidate overlaps. Archive rather than leave old versions online.
Keep articles focused
One article that covers refunds, shipping, and warranty produces chunks from all three topics. A narrower article gives cleaner matches and makes it clearer which article to correct when an answer is wrong.
Language and data categories
Each article version has one language. If you support several languages, plan for each one. A retriever can filter on language later, but only if the language field is part of what you ingest. The query above filters on en_US for this reason.
Data categories organize articles into a hierarchy, such as product line or region. They also control which users can see which articles. If you use categories for visibility, note them now. Chapter 17 covers how sharing applies to grounded answers, and chapter 10 covers filtering on fields at retrieval time. Decide early which of these fields you need, because it is easier to include them in the first ingestion than to add them later.
Channels and visibility
Knowledge articles can be published to channels such as internal users, customers, partners, or a public site. A common problem appears when an article is visible only internally in Knowledge but is ingested into a shared index. The agent may then quote it to a customer. Review the channel setting for every article you plan to ingest, and exclude internal-only material, or filter it out when you build the retriever.
A preparation checklist
Run through this list for each set of articles you plan to ground on.
- Every needed article has a version with
PublishStatus = 'Online'. - The language of each article matches the language of expected questions.
- Titles name the topic specifically.
- Each section can be understood without the sections around it.
- Facts that matter are in text, not only in images or attachments.
- Duplicate and outdated articles are archived or merged.
- Internal-only content is identified so it can be excluded or filtered.
- You have noted which fields hold the answer text, the title, and the URL.
Common errors
- Draft instead of published. The article was corrected in a draft that nobody published. The agent still gives the old answer.
- Wrong language. Articles exist only in another language, so a query returns nothing for the customer's language.
- Vague titles. Titles such as "FAQ" or "Policy" give weak matching signals.
- Stale duplicates. An old article stays online and the retriever returns it next to the new one.
- Answer in an attachment. The article body only says "see attached", and the attachment is not indexed.
- Internal notes in public articles. Staff-only comments sit in the body of a customer-facing article and can appear in answers.
Exercises
Exercise
An agent keeps quoting a 14-day return window, but your team corrected the article to 30 days last week. The query for PublishStatus = 'Online' returns the article with a LastPublishedDate from three months ago. What is the most likely cause, and what do you do first?
Show answer
The correction is probably sitting in a draft version that was never published, so the online version still says 14 days. Publish the draft in Knowledge first. Then refresh ingestion and check that the new LastPublishedDate appears in the query.
Exercise
Rewrite this sentence so it works as a standalone chunk about a product called Pro Plan: "It includes five seats. Add more in settings."
Show answer
For example: "The Pro Plan includes five seats. Add more Pro Plan seats in the account settings." The rewrite names the subject in each sentence, so the chunk still makes sense when it is retrieved alone.