Salesforce -> raia Agent

As a user of Raia Agent, I want to automatically sync our Salesforce Knowledge Base articles into a Raia Agent as a single Markdown file. This will provide the agent with our comprehensive support and product information, enabling it to assist customers and internal teams effectively.

Proposed Workflow (Hybrid Approach):

The n8n workflow should run on a nightly schedule and perform the following actions:

  1. Authenticate with Salesforce: Use OAuth 2.0 to obtain an access token.

  2. Fetch All Published Articles: Use the Salesforce REST API to get a list of all published knowledge base articles. The recommended approach is to use the Articles List API for discovery and then SOQL for fetching detailed content.

  3. Get Full Article Details: For each article, retrieve the full content, including custom fields, by querying the specific article type object (__kav).

  4. Organize by Data Categories: Use the data category information associated with each article to build a hierarchical structure.

  5. Generate Markdown: Create a single, well-structured Markdown file that organizes the content by data category, with articles nested underneath. Each entry should include the title, summary, full content, and any relevant metadata (e.g., article number, last published date).

  6. Upload to Raia Agent: Upload the generated Markdown file to the Raia Agent using the API.

Acceptance Criteria:

  • An n8n workflow is created that successfully authenticates with Salesforce using OAuth 2.0.

  • The workflow fetches all Online articles from the Salesforce Knowledge Base.

  • The workflow correctly organizes articles by their data categories.

  • The workflow consolidates the data into a single Markdown file.

  • The workflow successfully uploads the Markdown file to the Raia Agent via the API.

  • The workflow is scheduled to run every night.

  • The workflow includes robust error handling and notifications.

Technical Details:

  • Salesforce REST API:

    • Authentication: OAuth 2.0 (Username-Password Flow or JWT Bearer Token Flow recommended for server-to-server integration).

    • Articles List Endpoint: GET /services/data/vXX.X/support/knowledgeArticles

    • SOQL Query Endpoint: GET /services/data/vXX.X/query

    • Knowledge Article Object: Knowledge__kav (and custom article type objects ending in __kav).

  • Raia Agent API:

    • Endpoint: POST /external/agent-files/upload

    • Request Type: multipart/form-data

    • Authentication: API Key in the header.

    • Request Body:

      • file: The Markdown file to upload.

      • autoAddToVectorStore: true.

Implementation Notes:

  • Authentication: The developer will need to set up a Connected App in Salesforce to get the necessary client ID and secret for OAuth 2.0.

  • Article Types: Salesforce Knowledge can have multiple article types, each with its own set of custom fields. The workflow must be able to handle different article types and query them accordingly.

  • Pagination: Both the Articles List API and SOQL queries have limits on the number of records returned per request. The workflow must handle pagination to retrieve all articles.

  • Language Support: The workflow should specify the desired language in the Accept-language header to fetch the correct article versions.

  • Data Categories: The developer should leverage the data category information to create a meaningful structure in the final Markdown file.

Last updated