Ask Martech v3.0: How I Built My Own Chatbot on WordPress Using Cloudflare

Martech Zone grew large enough to attract bots that were looking for nothing in particular. They fired random terms at WordPress search, a query string at the end of the address, and each request made the database scan the archive. The admin timed out. Server resources kept spiking, and my site health was a rollercoaster. I wrote about this (and the solution) in How to Prevent Resource Exhaustion Attacks on WordPress Search.
I decided to disable search altogether and replaced that public query-string search with a chatbot. A box that accepts any string and runs it across every post is an invitation. The reply uses the content of the site to put context around the question: what this archive actually says, which page said it, and what it leaves unsaid.
Why didn’t I just use a third-party chatbot? This is a key question and there are a few reasons. Primarily, by having the chatbot self-hosted, I removed all of the terrible CWV impact that most chatbots incur. My chatbot doesn’t impact site speed whatsoever. Second, I have some custom post types and unique data associated with my site, like acronyms, a conference calendar, and retail holiday calendar. Those required some unique processes.
I started this with a very rudimentary chatbot built using Cloudflare services after reading how Joost de Valk built his. My first results weren’t that great, but it was a start. Now, quite a few versions later, users can ask questions like How do I set up DMARC? The chatbot responds in detail.
How Ask Martech Reached v3.0
Ask Martech started as that replacement. The first useful version was retrieval-augmented generation (RAG). Passages from the archive were embedded, and a model drafted only from what came back. The next section says what those two actions actually are.
Retrieval had to get stricter before the writer got larger. At one point, a shared tag was enough to let the newest post outrank the page that defined the term. Calendar questions needed their own sense of which month was actually being asked about. The writer then moved to gpt-oss-120b, which can stay with a longer excerpt and still answer briefly.
The remaining mistakes weren’t missing pages. They were sentences that combined two articles or gave a first-person line to the person the visitor had named. Clef-flash now checks a page before the draft, and checks a sentence after it. After the nearest passages are scored, a cross-encoder reranker reads the question against each candidate and reorders the short list, while the title and calendar boosts still apply. AI Gateway sits on every model call, so it logs the calls, retries a failed one, and caches identical requests. The window you open today is labeled v3.0. The Cloudflare Worker behind it is version 1.2.8.
WordPress and Cloudflare
WordPress still holds the library and the chat. I packaged all of this into a WordPress plugin for easier management. I wrote it largely with Claude first, and now Grok. It queues the index, renders the widget, and signs the requests to the edge. Cloudflare Workers run the retrieval and call the hosted models. The question is answered from this archive.
Two programs do that work. The WordPress plugin keeps the articles, the widget, and the settings. The Cloudflare Worker retrieves the passages, judges them, and writes the reply. A question goes from the browser straight to the Worker. A publish reaches the Worker only after cron, and only with a signature.

What Retrieval-Augmented Generation Actually Does
A chat model on its own answers from patterns it learned in training. It has no window into the articles on Martech Zone, and a smooth sentence is easy for it to invent. Retrieval-augmented generation changes the order of the work. First the system retrieves passages from this archive. Then the model writes a reply from those passages. The archive stays the source. The model is the writer.
Picture a closed-book assignment. You hand someone a few highlighted printouts and a question, and you tell them to answer from the printouts. If the printouts never mention the step, they say so. They do not fill the gap from memory. That is the whole design. The machinery below is how the printouts are chosen, and how a second reader checks the sentences after they are written.
Embedded is the part that sounds more mysterious than it is. A passage goes to an embedding model, and the model returns a long row of numbers. You cannot read the numbers as a summary. They are a position. Two passages about setting up email authentication sit near each other. A passage about a conference sits somewhere else. The question is converted with the same model, and the search is a nearest-neighbor lookup: which stored rows are closest to the question’s row?
The words are stored beside those numbers. Finding a nearby row only tells the system which passage to open. The writer later reads the words. It never sees the row of numbers. Closest is still only a first pass. A second model then reads the question next to each shortlisted passage and scores how well that passage actually answers it.
How a Published Article Joins the Library
When a post is published or updated, the plugin does not call out during the save. It queues a signed request, and the editor returns immediately. A deferred cron run delivers that request about thirty seconds later, once WordPress cron actually runs. Unpublishing removes that URL from the index.
The library lags a new article by that cron gap. A question asked in the gap still uses the previous passages for that address. After the run, those passages are replaced with the new ones.
An article is too long to store as one position. The Worker cuts it into passages of a few paragraphs, about 500 tokens, with a short overlap. A token is a piece of a word, so a passage is a section, not the whole page. The overlap keeps a step that lands on the cut inside the next passage as well, so the setup instructions are less likely to be sliced in half and lost.
Each passage is embedded with bge-base-en-v1.5 on Workers AI. That is the same model used later on the question, which is required. Two different embedding models would draw two different maps, and closest would be meaningless. While the numbers are calculated, the page title and its topics are placed in front of the passage. A short question can then land near a page whose title names the subject, even when the matching words are a small part of the body. The passage stored for the writer does not include that prefix. It is the article text.
The rows of numbers go to Vectorize. The passage text, the titles, and the topic keys go to Workers KV, a key-value store (KV). Read those as two shelves. Vectorize is the map of positions. Workers KV is the cabinet that holds the words. A lookup starts on the map and finishes by pulling the text from the cabinet.
Conferences and retail holidays are their own content, separate from ordinary posts. Dates are read in America/Indiana/Indianapolis, the site timezone. A question about this month is answered against that clock, not against UTC, which would already be tomorrow on many evenings here.
How One Question Moves Through the System
Open Ask Martech Zone and type “How do I set up DMARC?” The widget sends that sentence to a Cloudflare Worker and waits for a finished answer. WordPress search does not run. Nothing scans the database for those words.
These are the requests, in the order they happen.

- The Worker cleans the question. Extra spaces come out, and a very long question is cut off. This one is short, in English, and it names a subject, so it is looked up as written. The chat window sends the last three questions and answers with each new question. A follow-up that leans on them, such as “How do I implement it?” after “What’s SPF?”, is rewritten into a standalone question before the lookup. When the previous question named its subject and the follow-up has a single “it”, that subject takes its place: “How do I implement SPF?” Anything else, such as “vs SPF?” or “And Cyber Monday?”, goes to a small, fast Llama model that writes one standalone search query. A question that names a new topic is looked up as written, so the earlier turns do not pull it back. Words such as “this month” are rewritten to the real month on the Indianapolis clock before the lookup, so the embedding is not left to guess which month you meant. A supported non-English question is translated to English with m2m100 before this lookup, and the reply can be written in the visitor’s language.
- bge-base-en-v1.5 turns the question into a row of numbers. It is the same kind of row that was stored for every passage. This request is an embedding call. It does not write an answer.
- Vectorize returns the passages whose rows sit closest. Closeness means the same neighborhood. It does not yet mean the page answers the question.
- Title and topic signals then adjust that order. A title that matches the question is lifted. A tag can support a page the numbers already found. A shared tag does not give every tagged page one flat score. That flat score used to let the newest tagged post outrank the page that defined the term. Calendar questions also get a proximity score so this month is preferred over a later one.
- The passage text is loaded from Workers KV. The map found the shelf. The cabinet supplies the words the later steps will read.
- bge-reranker-base then reads the question next to each of the top passages. This is a cross-encoder: one model call scores the question and the passage together, instead of comparing two separate rows of numbers. The top 24 candidates are scored this way. Those scores are combined with the title, calendar, and content-type boosts already applied, so a definition page or this month’s holiday calendar can still rise. If the reranker errors, times out, or returns nothing usable, the previous ranking is kept. Passages that were not in that short list stay behind it, so an earlier raw score cannot jump back over the reranked pages.
- Clef-flash reads each retrieved page against the question and returns a probability that the page supports an answer. It still does not write the reply. A page under 0.35 is set aside, unless the title is a strong match, the page is a calendar, or the page is a knowledge base answer whose question matched exactly. If the check fails, returns no probability, or would drop every page, the ranked list stands. A weak page from the archive is safer than an answer drawn from a page the archive does not contain.
- The pages that remain are numbered and handed to gpt-oss-120b with your question. The instructions say to use only those excerpts, to call the publication Martech Zone, and to number the steps of a how-to. The model does not open the rest of either article, and it does not open the web. On a November 15, 2026 run of this DMARC question, the writer received the DMARC record builder and the guide to what DMARC is. Neighboring pages about report viewing and deliverability were retrieved, then set aside by the support check.
- Clef-flash reads the draft next. A sentence that cites a source is checked against that source. A name, or any title-case phrase of two or more words, has to appear in the supporting text. Martech Zone’s own name is exempt, because every source is a Martech Zone page. If a name is missing, that sentence is removed and is not restored. A sentence whose link appears word for word in a source is kept, and so is a yes that names a retrieved page by its title. When nothing remains, you see one line: Martech Zone does not say that.
- Because the question begins with How do I, the reply is treated as steps. Top-level bullets are renumbered. Sub-items under a step are folded onto that step’s line, separated by semicolons, so a nested list cannot turn into extra steps. A question that asks what the options are stays a bullet list. The widget draws the marker on the same line as the item’s first word.
- You then see the reply, citations such as [1], and the source titles under the reply. That DMARC run came back as a numbered procedure for publishing a
_dmarcDNS TXT record, with those two pages underneath. Open the citations and compare the steps to the pages. That comparison is the check you have as a reader. If a later change pulls a more direct setup page into the prompt, the steps can change.
While retrieval is being tuned, list mode returns the ranked pages and doesn’t call the writer at all. That shows the neighborhood before Clef-flash and the writer narrow it.
Each service in that path has one job:
| Tool | Job |
|---|---|
| Vectorize | Finds passages whose meaning sits near the question. |
| Workers KV | Holds the passage text, title keys, topic keys, and ranking settings. |
| bge-base-en-v1.5 | Turns pages and questions into rows of numbers on one map. |
| bge-reranker-base | Scores the question against each shortlisted passage and reorders that list. |
| gpt-oss-120b | Writes the reply from the excerpts that remain. |
| Clef-flash | Returns a support probability. It does not write the chat reply. |
| m2m100 | Translates a supported non-English question into English, and can translate titles back. |
| AI Gateway | Logs every model call, retries a failed one, and caches an identical request for ten minutes. |
None of those services replace the archive. They decide which published sentences are allowed into the reply.
Why the Nearest Page Is Not Always the Right Page
The DMARC trace is the reason the early quality work was ranking, not a bigger writer. A flat topic score wiped out the difference between two posts that share a tag. The topic signal now corroborates the vector score, and a tag-only candidate sits lower, as a fallback.
Closest on the embedding map is still only a first guess. Two passages can sit near the question and still not be equally useful: one may define the term, and another may only mention it. The reranker reads the question and the passage together and prefers the page that actually answers it. Those new scores are fused with the title and calendar boosts, so a “what is” question can still surface the acronym page, and a question about upcoming holidays can still prefer this month.
Calendar questions use a separate proximity score so a request for this month prefers this month’s bucket. Change those knobs only after scoring the same questions before and after. The writer never sees that machinery. It only sees the passages that survived it.
What the Writer Is Allowed to Know
By the time the writer runs, its world is your question plus a handful of numbered excerpts. The writer is gpt-oss-120b, an open model from OpenAI, running on Workers AI. An earlier instruct model could draft from excerpts. This one follows a longer passage and still answers briefly. It is an LLM used as a writer, not as a source. Temperature stays low because the job is to state a supported fact, not to invent a smoother one. Any reasoning the model does stays inside the call. The visitor does not see it.
The prompt treats the numbered excerpts as independent articles. A book, a job, or a date in one excerpt is not borrowed for the subject of another. Inside a source, I and we belong to the person who wrote that article. They do not belong to the person, company, or product named in the question. When the reply names this publication, it says Martech Zone.
That rule is there because a larger writer fixed fluency and still mixed people up. Two excerpts can sit in the same prompt: I might mention a writer and a personal anecdote about a company or technology I worked with that illustrated the book. Now the logic is inaccurately making a connection to my anecdote and their work. The excerpt never did. Retrieval did not make that mistake. The draft did. Finding a better page would not have stopped it, because both pages were real. The sentence that combined them was not.
The Check Before the Draft and the Check After It
The support checks in the walkthrough are the same tool, run twice. Clef-flash on Workers AI returns a probability that a statement is supported. The writer stays the writer. Clef-flash never replaces it.
Before the draft, one call scores each retrieved page against the question. That is what narrowed the DMARC neighborhood down to the pages the writer was allowed to see. A page under 0.35 is dropped, unless the title is a strong match, the page is a calendar, or the page is a knowledge base answer whose question matched exactly. If the check fails, returns no probability, or would drop every page, the original ranking stands.
After the draft, a second call scores each cited sentence against the sources it names. A sentence with no citation stays, unless it assigns a book, a job, or an employer, or states what Martech Zone accepts, sells, or refuses. Those claims are checked against every excerpt. A name, or any title-case phrase of two or more words, has to appear in the supporting text. Martech Zone’s own name is exempt, because every source is a Martech Zone page, and an acronym such as SPF does not make a phrase a name. If a name is missing, that sentence is removed and is not restored. A sentence whose link appears word for word in a source, such as the Collaborator link for guest post and backlink requests, is kept without that check. So is a yes that names a retrieved page by its title, such as the ROAS Calculator. When nothing remains, the visitor sees one line.
Martech Zone does not say that.
Ask Martech, when the excerpts do not name the subject
If the judge rejects every sentence on probability alone, the draft is kept. A list of upcoming holidays should not vanish because a cautious score disliked the format. A leading yes stays attached to the sentence it introduces, so the yes cannot remain after that sentence is removed.
Where Every Model Call Is Logged
The embedding, the reranker, the writer, both Clef-flash checks, and translation all go through AI Gateway, under the ID martech-ask. The gateway logs calls, retries a failed call up to three times, and caches identical requests for ten minutes. Ask the same question twice in that window and the second reply can come from the cache. The prompt includes today’s date, so a cached answer about what is upcoming cannot still be upcoming tomorrow. The Worker also records its own invocation logs, so a slow or failed retrieval step can be inspected without guessing. Create the gateway in the Cloudflare dashboard. The credential that deploys the Worker is not allowed to create one.
What You See in the Window
The header reads Ask Martech Zone, with a small v3.0 beside the title. That label lives in the WordPress plugin and has not been changed with the Worker. A citation such as [1] becomes a link to that source, and the source titles sit under the reply. For the DMARC question, those titles are the pages the writer was given. Procedures stay numbered, including when the writer emits dashes. A question that asks what the options are stays a bullet list, including when the writer emits numbers. The marker and the first words of each item share a line. Sub-items under a step are folded onto that step’s line. Line-range markers the writer sometimes adds to a citation, such as 【1†L84-L86】, are reduced to [1]. Code in the dark theme stays light on a light chip.
The Plugin Settings Pages
In WordPress admin, the menu is Ask Martech. Configuration stores the Worker URL, the shared secret, and which post types are indexed. Index Management holds rank tuning and the calendar refresh. Chat Widget holds the title, the colors, and the avatar. Point the plugin at the Worker on Configuration before the first index run.

Version History
These are the Worker versions recorded in the source, plus the dated changes that led to them. I have not invented the missing numbers. The chat window says v3.0.
- Worker 0.1.0, May 5, 2026. The first import of the Worker. Questions were embedded with bge-base-en-v1.5, stored in Vectorize and Workers KV, and drafted by Llama 3.3 70B Instruct.
- May and July 2026, still under 0.1.0 in the Worker package file. Author pages, tag and topic signals, and the retail-holiday and conference calendars were added to retrieval. Calendar proximity and date handling were pinned to the site timezone. On July 7, 2026, the writer moved from Llama 3.3 70B Instruct to gpt-oss-120b. Non-English questions began going through m2m100.
- Worker 1.0.0, August 4, 2026. The retrieval rewrite was deployed and verified. The Worker version string in the source moved from 0.1.0 to 1.0.0.
- Worker 1.2.7, first recorded in the source on October 20, 2026. Clef-flash began checking a retrieved page before the draft and a cited sentence after it, and the reply started citing the supporting pages. The repository does not record Worker versions 1.2.1 through 1.2.6.
- Worker 1.2.8, November 15, 2026. After the weighted candidate pool is built, the top 24 passages are scored with bge-reranker-base and fused with the existing title, calendar, and content-type boosts. If that call fails, the previous ranking is kept. Worker invocation logs were turned on, and leftover six-hour cron on a Worker with no scheduled handler was removed.
- Worker 1.2.9, November 16, 2026. Follow-up questions are rewritten into standalone search queries before retrieval, using the earlier turns the chat window sends.
- Worker 1.2.10 through 1.2.12, November 18, 2026. The chat window on the site was updated to send the earlier turns, so follow-ups now resolve. A follow-up with “mine” or “yours” also triggers the rewrite, and a single “it” is replaced with the previous question’s subject without a model call. The sentence check keeps a sentence whose link appears in a source and a yes that names a retrieved page by its title, ignores Martech Zone’s own name, and checks uncited statements about what Martech Zone accepts or sells. A knowledge base answer whose question matched exactly is no longer dropped before the draft. Nested list items are folded into their step, and line-range citation markers are reduced to [1]. The name check no longer counts a sentence’s first word, a possessive, or an acronym such as SPF as part of a name. An answer that points to Collaborator drops any sentence without the link that states a policy or mentions paid links.
What a Question Still Cannot Do
The answer comes from the indexed archive. There is no live web search beside it. The bot cannot credit an author the passage never names. It will refuse a claim rather than borrow one from a neighboring article. That refusal is what the later checks are for. Finding pages came first. Deciding whether a sentence may stand came after. Leave the 0.35 floor where it is until the same questions are scored with the check on and off.
You can ask How do I set up DMARC? yourself and compare the citations with the walkthrough above. As the pages that survive, and the steps in the reply, keep improving, those examples will change with them.







