Link Auditor And Fixer
Prompt
How it works
Crawling and Link Extraction (Read Phase - Data API)
- Pages: Get all pages with
data_pages_tool(list_pages). For each page, read its elements usingdata_element_tool(get_all_elements). Parse the content to find all link elements, their URLs, and their unique node IDs. Store the mapping:{pageId, nodeId, url, linkText}for each link found. Note: Links may appear astype: 'text'nodes with HTML containing<a>tags, or astype: 'Link'elements. The nodeidfield can be used directly indata_element_toolcalls. - CMS: Get all collections with
data_cms_tool(get_collection_list). For each collection, get all items usingdata_cms_tool(list_collection_items). For each item, iterate through its fields and parse any rich text content to find links.
Validation
For each unique link found, make a network request to check its status.
If a link returns a 4xx or 5xx status code, it’s “broken” and flagged for manual review.
If a link starts with http://, try the https:// version. If the HTTPS version works, the link is “insecure” and a fix will be proposed. If the HTTPS version fails, it is flagged for manual review.
Planning (Dry Run)
Compile a list of all proposed changes (e.g., “On the ‘About Us’ page, change http://example.com to https://example.com”).
Compile a separate list for links that need manual review.
Present both lists to the user for approval.
Execution (Write Phase - Data API)
- Pages: For links on static pages that need fixing:
- Locate the link element with
data_element_tool(query_elementsorget_all_elements), passingsiteIdand thepageIdfrom the crawling phase; match on thenodeId(or filter bytype: 'Link'). - Use
data_element_toolwith theset_linkaction on that element, passinglinkType(e.g., ‘url’, ‘page’, ‘email’) andlink(the corrected URL or target).
- Locate the link element with
- CMS: For links in CMS items, use
data_cms_tool(update_collection_items) to write the corrected link into the rich text field, thendata_cms_tool(publish_collection_items) to publish the change live.