feat(salesforce): add Knowledge AI connector with role-based agent/supervisor indexing#889
feat(salesforce): add Knowledge AI connector with role-based agent/supervisor indexing#889Mattallmighty wants to merge 10 commits intoCognigy:masterfrom
Conversation
… status ID bug
searchContact:
- Replace SELECT FIELDS(All) with a two-step approach (SELECT Id + sobject.retrieve)
to avoid requiring the "View All Data" Salesforce permission, which was causing 400
errors across orgs
- Change LIKE to = to support orgs with Salesforce Shield encryption on fields such
as Email, where LIKE is not a supported operator
- Add ORDER BY CreatedDate DESC for deterministic results when multiple records match
- Add onErrorContact child node so errors route correctly instead of crashing with
"Cannot read properties of undefined (reading 'id')"
- Add null guard on onErrorChild to prevent cascade crash if child is not yet wired
in an existing flow
- Improve error logging to include Salesforce response body for easier debugging
createCase:
- Fix Status optionsResolver returning status.Id (the CaseStatus metadata record ID)
instead of status.MasterLabel (the actual picklist string value e.g. "New"), which
was causing cases to be created with an ID in the Status field rather than the
human-readable value
authenticate:
- Fix missing semicolon on closing brace of exported arrow function (lint error)
* Features: * - Local state file (import-state.json) tracks what's been imported and when * - Skip articles that are already up-to-date (same LastPublishedDate) * - Delete + recreate articles whose content has changed * - Retry with exponential backoff on 405/429/502/503 * - --from=N flag to resume from a specific article index (1-based)
htmlFieldToMarkdown() (replaces stripHtml) Converts HTML to proper Markdown instead of stripping it flat. Headings inside a field are shifted down (e.g. <h2> inside an Overview field → ####) so they sit correctly below the ## Overview field label.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
There was a problem hiding this comment.
Pull request overview
Adds a Salesforce Knowledge connector to the Salesforce extension, enabling ingestion of published Salesforce Knowledge articles into Cognigy Knowledge AI with role-based (agent vs supervisor/manager) separation, plus a couple of related Salesforce node/package updates.
Changes:
- Introduces a new
salesforceKnowledgeConnectorthat queries published Salesforce Knowledge articles, converts field HTML to Markdown, chunks content, and creates agent/supervisor-tagged sources. - Adds a small Cognigy Management API wrapper to list/delete knowledge sources for stale cleanup use cases.
- Updates the Salesforce extension module registration and improves the
searchContactnode’s branching/error handling; adjusts Case Status option mapping.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| extensions/salesforce/src/nodes/searchContact.ts | Adds an explicit On Error branch and switches to an ID lookup + sobject.retrieve() for full record retrieval. |
| extensions/salesforce/src/nodes/createCase.ts | Changes Case Status select option values to use MasterLabel (picklist value) instead of Id. |
| extensions/salesforce/src/module.ts | Registers the new Salesforce Knowledge connector and the new onErrorContact node. |
| extensions/salesforce/src/knowledge-connectors/salesforceKnowledgeConnector.ts | New connector implementing role-based indexing, HTML→Markdown conversion, chunking, and stale-source cleanup logic. |
| extensions/salesforce/src/knowledge-connectors/cognigyManagementApi.ts | New axios wrapper for listing/deleting knowledge sources via Cognigy Management API. |
| extensions/salesforce/src/authenticate.ts | Small formatting/termination fix. |
| extensions/salesforce/package.json | Version bump and dev dependency additions. |
| extensions/salesforce/package-lock.json | Lockfile updates for the dependency changes. |
Files not reviewed (1)
- extensions/salesforce/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- searchContact: escape single quotes in SOQL string literal to prevent injection
- sanitizeText: preserve printable Unicode (accented chars, CJK, etc.) — only
strip C0/C1 control characters, not all non-ASCII
- salesforceKnowledgeConnector: guard agentFields/supervisorFields with
Array.isArray so undefined supervisorFields doesn't throw at runtime
- salesforceKnowledgeConnector: validate lastSyncDate as ISO 8601 before
embedding in SOQL; throw a descriptive error on invalid input
- salesforceKnowledgeConnector: prefix source names with [SF:<articleNumber>]
so stale-removal pattern is unambiguous in shared knowledge stores
- cognigyManagementApi: strip trailing slashes from apiUrl before building
request paths to prevent double-slash issues
- package-lock.json: regenerate to sync version with package.json (4.5.1)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 3 comments.
Files not reviewed (1)
- extensions/salesforce/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Files not reviewed (1)
- extensions/salesforce/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Adds a Salesforce Knowledge connector for Cognigy Knowledge AI that imports published Salesforce Knowledge Articles into a Cognigy Knowledge Store, with configurable role-based content separation between agent-facing and supervisor/manager-only views.
Changes
src/knowledge-connectors/salesforceKnowledgeConnector.ts(new)Role-based content separation
Each article produces up to two knowledge sources:
Overview__c,Details__c,Processing_Steps_Text__c) and applies a configurable agent tag. Agent Copilot filters by this tag.Manager_Actions__c,Manager_scripting__c) and applies a configurable supervisor tag. Only created when the article actually has content in those fields. Supervisor Copilot filters by both tags to surface the full article.Robust text processing pipeline
resource-nameformat — handles en/em dashes, ampersands, parentheses, slashes, and other special characters commonly found in Knowledge Article titlesChunk metadata
Each chunk carries
articleNumber,role(agent/supervisor), andurl(Lightning URL to the source article) for context display in Agent Copilot.Fully configurable via the connector UI
Knowledge_Article__kaven_UStextArray— no code changes needed["agent"]["supervisor"]src/knowledge-connectors/cognigyManagementApi.ts(new)Thin axios wrapper providing paginated listing and deletion of knowledge sources — operations not exposed by to support incremental sync use cases.
src/module.ts(modified)Registers
salesforceKnowledgeConnectoralongside the existing Salesforce nodes.SOQL Query