Read a Shopify Community discussion and return its structured conversation content.
Use Cases
Use for any Shopify Community thread when the thread URL or its /t/{slug}/{numeric-id} path is known.
Automation Flow
- Navigate directly to
https://community.shopify.com/t/{slug}/{thread-id}. Shopify Community uses Discourse-style thread URLs with an opaque numeric ID; preserve the ID rather than guessing it. - After the page has loaded, run this evaluator once on the current page:
(() => {
const text = (el) => (el?.innerText || "").replace(/\s+/g, " ").trim();
const title =
text(document.querySelector("h1.fancy-title, h1[data-topic-id]")) ||
document.querySelector('meta[property="og:title"]')?.getAttribute("content")?.trim() ||
document.title.replace(/\s*[|—-]\s*Shopify Community.*$/i, "").trim();
const posts = [
...document.querySelectorAll(
".topic-post[data-post-id], article.topic-post, .topic-post",
),
]
.map((post, index) => {
const author =
text(
post.querySelector(
".topic-meta-data .names a, .names a.username, a.username",
),
) || null;
const timeEl = post.querySelector("time[datetime], .post-date time");
const body = text(
post.querySelector(".topic-body .cooked, .cooked, .topic-body"),
);
return {
index: index + 1,
postId: post.getAttribute("data-post-id") || null,
author,
timestamp: timeEl?.getAttribute("datetime") || text(timeEl) || null,
text: body,
};
})
.filter((post) => post.text);
return { title, url: location.href, posts };
})();Possible Friction Points
- Shopify Community is powered by Discourse; the durable route format is
/t/{slug}/{numeric-id}. - Do not infer or fabricate the numeric thread ID from the title. If only a topic name is available, resolve it through Shopify Community search first and use the ID from the matching result.
- A thread can contain multiple post types and nested controls, so extract only
.cookedpost bodies rather than page-wide text. - The page may hydrate posts after initial DOM load; wait for the topic posts to appear before evaluating if the initial result is empty.