Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integrations/apify/integration.definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const startCrawlerRunInputSchema = z.object({

export default new IntegrationDefinition({
name: 'plus/apify',
version: '1.0.3',
version: '1.0.4',
title: 'Advanced Website Crawler',
readme: 'hub.md',
icon: 'icon.svg',
Expand Down
9 changes: 8 additions & 1 deletion integrations/apify/src/helpers/botpress-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import * as bp from '.botpress'
export class BotpressHelper {
constructor(private bpClient: bp.Client) {}

async uploadFile(filename: string, content: string, extension: string, kbId: string): Promise<void> {
async uploadFile(
filename: string,
content: string,
extension: string,
kbId: string,
sourceUrl?: string
): Promise<void> {
// Ensure filename is not too long and has valid characters
const safeFilename = filename.substring(0, 100).replace(/[^a-zA-Z0-9_-]/g, '_')
const fullFilename = `${safeFilename}.${extension}`
Expand All @@ -14,6 +20,7 @@ export class BotpressHelper {
kbId: kbId,
dsType: 'document',
source: 'knowledge-base',
...(sourceUrl ? { sourceUrl } : {}),
},
content: Buffer.from(content, 'utf8'),
contentType: this.getContentType(extension),
Expand Down
5 changes: 4 additions & 1 deletion integrations/apify/src/lib/sync-orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export class SyncOrchestrator {
for (const item of items) {
const url = item.url || item.metadata?.url || 'unknown'

this.logger.forBot().debug(`🔗 Original URL from Apify: ${url}`)

try {
const processedItem = this.dataTransformer.processItemContent(item)
if (!processedItem) {
Expand All @@ -83,6 +85,7 @@ export class SyncOrchestrator {
}

const filename = this.dataTransformer.generateFilename(item)
this.logger.forBot().debug(`📄 Generated filename: ${filename} ← ${url}`)

// retry on 409
let retries = 5
Expand All @@ -93,7 +96,7 @@ export class SyncOrchestrator {

while (retries > 0) {
try {
await this.botpressHelper.uploadFile(filename, processedItem.content, processedItem.extension, kbId)
await this.botpressHelper.uploadFile(filename, processedItem.content, processedItem.extension, kbId, url)
filesCreated++
this.logger.forBot().debug(`✓ Uploaded: ${filename} (${url})`)
break
Expand Down