Orchardcore ai web crawlers

From CrestApps/CrestApps.AgentSkills · View interactive version

Orchardcore ai web crawlers is an AI agent skill from the GitHub repository CrestApps/CrestApps.AgentSkills. Skill for CrestApps AI Web Crawlers in Orchard Core 4.0 (CrestApps.OrchardCore 3.0). Covers the Web AI data source, strategy-based web crawlers with the built-in Sitemap strategy, sitemap discovery from robots.txt, include and exclude URL patterns, page limits, concurrency and timeouts, incremental

How to use this skill

Skill file

Orchard Core AI Web Crawlers

Scrape public websites into the AI knowledge base

You are an Orchard Core expert. Generate configuration and code for CrestApps web crawlers: a Web AI data source is a knowledge base target, and one or more web crawlers point at it. Each crawler scrapes one site with a crawl strategy, cleans each page to text, and indexes it with its URL kept for citations.

Guidelines

Setup

  1. Create a knowledge base index under Search > Indexing with an embedding deployment.
  2. Under Artificial Intelligence > Data Sources, choose Add Data Source, pick Web, and select the destination index.
  3. Under Artificial Intelligence > Web Crawlers, choose Add Web Crawler, pick Sitemap, and fill the fields below.
  4. Use Synchronize now in the row's Actions menu, or wait for the hourly task.
  5. Attach the Web data source to an AI profile or chat interaction on its Knowledge tab.

A recipe can create the Web data source ("Source": "Web" in the AIDataSource step, see orchardcore-ai-data-sources), then its crawlers with the WebCrawlers step. A crawler is matched by ItemId, then by DisplayText within the same strategy, so running the recipe twice adds nothing. Source must be a registered strategy and AIDataSourceId must name a Web data source, so import data sources first.

{
  "steps": [
    {
      "name": "WebCrawlers",
      "Crawlers": [
        {
          "ItemId": "4wc00000000000000000000001",
          "Source": "Sitemap",
          "DisplayText": "Help center",
          "AIDataSourceId": "4ds00000000000000000000002",
          "Enabled": true,
          "ReindexIntervalMinutes": 1440,
          "Properties": { }
        }
      ]
    }
  ]
}

The Web crawlers deployment step (Artificial Intelligence category) exports every crawler with its strategy settings in Properties. Secrets are never exported, and a recipe that leaves one out keeps the stored one. With AI Chat WebAPI, crawlers are also managed through /api/ai/v1/web-crawlers (see orchardcore-ai-conversations).

Shared crawler fields

| Field | Stored as | Notes |

|---|---|---|

| Name | WebCrawler.DisplayText | Required |

| Target Web data source | WebCrawler.AIDataSourceId | Required; several crawlers may target one data source |

| Enabled | WebCrawler.Enabled | Disabled crawlers are skipped by the hourly task and by a full data source sync |

| Re-index interval (minutes) | WebCrawler.ReindexIntervalMinutes | Empty uses the default (24 hours); honored to the nearest hour |

Sitemap strategy

Stored in SitemapWebCrawlerMetadata on the crawler (WebCrawler.Source is Sitemap):

| Field | Property | Default |

|---|---|---|

| Base URL | BaseUrl | Discovers the sitemap from robots.txt and conventional locations such as /sitemap.xml |

| Sitemap URL | SitemapUrl | Starts discovery here; supports nested sitemap indexes, gzip, plain text, and RSS or Atom feeds |

| Max pages | MaxPages | 500 |

| Max concurrent requests | MaxConcurrentRequests | 4 |

| Request timeout (seconds) | RequestTimeoutSeconds | 30 |

| Include URL patterns | IncludeUrlPatterns | Empty allows every page; otherwise a URL must match at least one |

| Exclude URL patterns | ExcludeUrlPatterns | A URL matching any pattern is skipped; applied after include |

| User-Agent | UserAgent | CrestApps-WebCrawler/1.0 (+https://crestapps.com) |

Patterns are .NET regular expressions, one per line, matched against the full URL. Examples: ^https://example\.com/docs/ keeps only /docs/; /tag/|/author/ drops taxonomy and author pages; \.pdf$ drops PDF links. Invalid expressions and non-absolute URLs are rejected in the editor.

Synchronization

Crawlers and crawl state live in the AI YesSql collection through IWebCrawlerStore and IWebCrawlStateStore; migrations create WebCrawlerIndex and WebCrawlStateIndex.

Citations

Pages are indexed with the URL as the reference id, and WebCrawlerReferenceLinkResolver is registered for the Web reference type, so [doc:N] citations link back to the original page.

Defaults

WebCrawlerOptions holds the fallbacks used when a crawler leaves a field empty: DefaultMaxPages (500), DefaultMaxConcurrentRequests (4), DefaultRequestTimeoutSeconds (30), DefaultUserAgent, and DefaultReindexIntervalMinutes (1440). The Orchard module binds no configuration section to it; change it in code:

public sealed class Startup : StartupBase
{
    public override void ConfigureServices(IServiceCollection services)
    {
        services.Configure<WebCrawlerOptions>(options =>
        {
            options.DefaultMaxConcurrentRequests = 2;
            options.DefaultUserAgent = "ContosoBot/1.0 (+https://contoso.com/bot)";
        });
    }
}

Admin list and permissions

Artificial Intelligence > Web Crawlers is an AdminList named AIWebCrawlers with the grid columns Name, Strategy, Modified, and Actions; rows are the WebCrawler shape in SummaryAdmin and SummaryAdminGrid (see orchardcore-admin-lists). The whole area, including Synchronize now, requires ManageWebCrawlers (Manage web crawlers, Administrator by default).

Add a crawl strategy

A strategy is a keyed IWebCrawlerStrategy plus an entry in WebCrawlerStrategyOptions and a display driver for its settings:

public sealed class Startup : StartupBase
{
    internal readonly IStringLocalizer S;

    public Startup(IStringLocalizer<Startup> stringLocalizer)
    {
        S = stringLocalizer;
    }

    public override void ConfigureServices(IServiceCollection services)
    {
        services.AddKeyedSingleton<IWebCrawlerStrategy, LinkFollowingWebCrawlerStrategy>("LinkFollowing");
        services.Configure<WebCrawlerStrategyOptions>(options => options.AddOrUpdate(
            "LinkFollowing",
            S["Link following"],
            S["Discover pages by following links from a start page to a fixed depth."]));

        services.AddDisplayDriver<WebCrawler, LinkFollowingWebCrawlerDisplayDriver>();
    }
}

| IWebCrawlerStrategy member | Contract |

|---|---|

| Name | The strategy key, stored as WebCrawler.Source |

| ValidateAsync(crawler, result, cancellationToken) | Validate the strategy settings |

| DiscoverAsync(crawler, cancellationToken) | Return the CrawledPageRef list of pages to consider |

| DiscoverDetailedAsync(crawler, cancellationToken) | Optional; report whether discovery was complete (the default treats an empty list as incomplete) |

| FetchAsync(crawler, url, cancellationToken) | Fetch and clean one page, or return null |

The display driver returns null unless crawler.Source is the strategy key and stores its settings with crawler.Put(...). The built-in sitemap strategy is also exposed as an ingestion connector, the same contract file sources use (see orchardcore-ai-file-sources).

Troubleshooting

| Symptom | Check |

|---|---|

| No Web source type in Add Data Source | Enable CrestApps.OrchardCore.AI.WebCrawlers. |

| Provide a base URL or an explicit sitemap URL | Set one of them, as an absolute URL. |

| Few or no pages | The sitemap is not discoverable, include patterns are too narrow, or Max pages is low. |

| Site blocks the crawler | Lower concurrency, set a recognizable User-Agent, and confirm crawling is allowed. |

| Pages never refresh | The crawler is disabled, or its interval has not elapsed; use Synchronize now. |

| Citations have no links | The data source is not of type Web, or the page URL is not the reference id. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.