All Products
Search
Document Center

Data Transmission Service:Connect Feishu to a DTS RAGFlow knowledge base

Last Updated:Apr 26, 2026

This topic describes how to transfer data from Feishu to a RAGFlow knowledge base in Data Transmission Service (DTS).

Prerequisites

You have created a RAGFlow knowledge base in DTS and configured an IP whitelist.

Background

Supported data types

DTS RAGFlow supports transferring cloud documents, spreadsheets, multidimensional tables, and wikis from Feishu.

Access methods

You can use either an application access token (tenant_access_token) or a user access token (user_access_token) to access data in Feishu.

Method

Permission type

Pros

Cons

tenant_access_token (Recommended)

Application identity

  • Supports resumable transfer.

  • Requires only a one-time configuration for transferring a single folder or wiki.

The authorization process is complex and requires additional permission configuration for Cloud Drive and wikis.

user_access_token

User identity

The authorization process is simple. It grants access to all folders without requiring separate permission configurations for Cloud Drive and wikis.

  • You must obtain a new Feishu authorization code each time you run the KBSync program.

  • The obtained Feishu authorization code expires and must be re-obtained.

Preparation

  1. Sign in to the Feishu Open Platform and go to the Developer Console.

  2. Create an app.

    Click Create Custom App, configure the Name and App Description, and then click Create.

  3. Click the app card to go to the app editing page.

    The Basic Information > Credentials & Basic Information page opens by default.

  4. On the Credentials & Basic Information page, in the App Credentials section, record the App ID and App Secret.

Procedure

Note

For detailed instructions on Feishu operations, see the official Feishu documentation (Help Center and Developer Documentation).

Step 1: Configure access permissions

tenant_access_token

  1. Sign in to the Feishu Open Platform and go to the Developer Console.

  2. Click the app that you created in the Preparation section.

  3. Add a bot and publish the app.

    1. In the left-side navigation pane, choose App Features > Add App Features.

    2. On the Add by Feature tab, find the Bot card and click Add.

    3. At the top of the page, click Create Version.

      Note

      You can also choose App Release > Version Management & Release in the left-side navigation pane and then click Create Version.

    4. On the Version Details page, enter the Version Number and Update Description.

      Note

      Keep the default Bot setting for Default Mobile Capability and Default Desktop Capability.

    5. Click Save.

    6. In the dialog box that appears, click Confirm Release.

  4. Configure API permissions.

    1. In the left-side navigation pane, choose Development Configuration > Permission Management.

    2. Click Bulk Import/Export Permissions.

    3. On the Import tab, in the JSON text box, configure the following user identity permissions for the application.

      {
        "scopes": {
          "tenant": [
            "docs:document:export",
            "drive:drive",
            "wiki:wiki"
          ],
          "user": []
        }
      }
    4. Click Next, Confirm New Permissions.

    5. Click Request to Enable.

  5. Sign in to the Feishu client, create a new group, and add the app you created in the Preparation section as a group bot.

  6. Configure access permissions for Cloud Drive and wikis.

    Cloud drive permissions

    1. Go to the target Cloud Drive folder.

    2. On the right side of the page, click Share.

    3. In the Invite Collaborators field, enter the group that you created in Step 5.

      The default Reader permission is sufficient.

    4. Click Send.

    Wiki permissions

    1. Go to the All Wikis page.

    2. Hover over the target wiki and click Knowledge Base Settings.

    3. Click the Member Settings tab. In the Roles & Permissions section on the Administrator tab, click Add Administrator.

    4. In the dialog box that appears, add the group you created in Step 5 and click Next.

    5. Click Send.

user_access_token

  1. Sign in to the Feishu Open Platform and go to the Developer Console.

  2. Click the app that you created in the Preparation section.

  3. Configure API permissions.

    1. In the left-side navigation pane, choose Development Configuration > Permission Management.

    2. Click Bulk Import/Export Permissions.

    3. Configure the appropriate user identity permissions for the application created in the Preparations section.

      {
        "scopes": {
          "tenant": [],
          "user": [
            "offline_access",
            "docs:document:export",
            "drive:drive",
            "wiki:wiki"
          ]
        }
    4. Click Next, Confirm New Permissions.

    5. Click Request to Enable.

  4. Configure redirect URLs.

    1. In the left-side navigation pane, choose Development Configuration > Security Settings.

    2. In the Redirect URL text box, enter https://www.aliyun.com.

    3. Click Add next to the text box.

    4. Enable the Refresh user_access_token switch.

      Note

      If this switch is not visible, it is enabled by default.

  5. Obtain the authorization code.

    1. Construct the authorization page URL for Feishu.

      Note

      Replace YOUR_FEISHU_CLIENT_ID in the following URL with the App ID from the Prerequisites section.

      https://accounts.feishu.cn/open-apis/authen/v1/authorize?client_id=YOUR_FEISHU_CLIENT_ID&redirect_uri=https://www.aliyun.com&scope=drive:drive offline_access docs:document:export wiki:wiki
    2. Open the authorization page in a browser.

    3. Click Authorize.

    4. Obtain the authorization code (code) from the redirect URL.

      Note

      The authorization code does not include code=, &, or any information that follows the & symbol.

Step 2: Obtain folder token and wiki ID

  1. Sign in to the Feishu client.

  2. Obtain the token of the folder that contains your Feishu cloud documents.

    1. Go to the target folder.

    2. From the address bar at the top of the page, copy the URL for the folder.

    3. Obtain the token from the URL (the information after folder/).

      Note

      The token does not include the ? symbol or any text that follows it.

  3. Obtain the wiki ID.

    1. Go to the All Wikis page.

    2. Hover over the target wiki and click Knowledge Base Settings.

    3. From the address bar at the top of the page, copy the URL for the target wiki.

    4. Get the knowledge base ID from the URL (the information that follows settings/).

      Note

      The wiki ID consists only of numbers and does not include the # symbol or any text that follows it.

Step 3: Run the KBSync program

  1. Obtain the KBSync file.

    Note

    You can join the DingTalk group (ID: 79690034672) and contact technical support to obtain the KBSync file.

  2. Prepare the runtime environment for the KBSync program.

    Note

    The KBSync program requires a Linux environment with access to the Feishu Open Platform and RAGFlow.

  3. Prepare the configuration file named config.

    1. Create a Linux file named config.

    2. Copy the following content into the config file.

      whiteList=
      blackList=
      sinkType=RagFlow
      sourceType=FeiShu
      ragflowUrl=http://XX.XX.XX.XX
      ragflowApiKey=Bearer RAGFlow-BmND******MDI0Mm
      ragflowDatasetId=928d061******2ac120006
      feishuAppId=cli_a8a******d00d
      feishuAppSecret=pMp73Si******UDrWXBSOa
      feishuUserAccessCode=bGzpx6******B9KFCdzdCDHG
      feishuCloudSpaceDirToken=ESJm*******CRdn002cii3bnAc
      feishuWikiSpaceId=7504968******8674
    3. Replace the placeholder values in the config file with your values.

      Important
      • If a parameter is not required, leave its value empty.

      • If the feishuCloudSpaceDirToken and feishuWikiSpaceId parameters are both specified, only Feishu cloud documents and their parent folders are transmitted (only the feishuCloudSpaceDirToken parameter takes effect).

      • Parameter blackList has a higher priority than parameter whiteList.

      Parameter

      Required

      Description

      How to obtain

      whiteList

      No

      The paths to include (whitelist) or exclude (blacklist). Paths can be folder paths in Feishu Cloud Drive or document paths within a wiki.

      Note

      Regular expressions are supported. Separate multiple paths with spaces.

      Obtain the paths from the Feishu client.

      blackList

      No

      sinkType

      Yes

      The sink type.

      Set the value to RagFlow.

      sourceType

      Yes

      The source type.

      Set the value to Feishu.

      ragflowUrl

      Yes

      The RAGFlow API server address.

      See Obtain the API server address.

      ragflowApiKey

      Yes

      The API key for the RAGFlow knowledge base.

      Obtain the API key for the RAGFlow knowledge base.

      ragflowDatasetId

      Yes

      The RAGFlow knowledge base ID.

      See Obtain the knowledge base ID.

      larkAppId

      Yes

      The App ID of your Feishu app.

      See Step 4 in the Preparation section.

      feishuAppSecret

      Yes

      The App Secret of your Feishu app.

      feishuUserAccessCode

      No

      Note

      You need to pass parameters only when you access data in Feishu by using a user_access_token.

      The authorization code from Feishu.

      Obtain an authorization code.

      feishuCloudSpaceDirToken

      No

      Note

      Provide a value for only one of these two parameters.

      The token of the folder that contains the Feishu cloud documents.

      See Step 2: Obtain folder token and wiki ID.

      feishuWikiSpaceId

      The ID of the Feishu wiki.

  4. Place the KBSync file and the config file in the same directory in your Linux environment.

  5. In a Linux environment, execute the ./KBSync --config config command to run the KBSync program.

    If the output is similar to the following, the KBSync program has started successfully.

    ./KBSync --config config
    
    INFO config whiteList=, blackList=
    INFO config ragflowUrl=http://XX.XX.XX.XX/, ragflowApiKey=Bearer RAGFlow-BmND******MDI0Mm
    INFO config ragflowDatasetId=928d061******2ac120006
    INFO config feishuAppId=cli_a8a******d00d, feishuAppSecret=pMp73Si******UDrWXBSOa
    INFO Response from https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal: 200, headers: {'Server': 'Tengine', 'Content-Type': 'application/json', 'Content-Length': '102', 'Connection': 'keep-alive', 'Date': 'Tue, 08 Jul 2025 02:49:01 GMT', 'Request-Id': '25bf****-d386-4a86-****-f440f070****', 'Tt_st****': '1', 'X-Lgw-Dst-Svc': 'jbpiSR****OiA0J3d****-Oz0xugYAH9otZIFg4x****', 'X-Request-Id': '25bf****-d386-4a86-b9f4-f440f070****', 'X-Tt-Logid': '202507081049012933B870245850D****', 'server-timing': 'inner; dur=73, cdn-cache;desc=MISS,edge;dur=0,origin;dur=129', 'x-tt-trace-host': '****', 'x-tt-trace-tag': '****', 'x-tt-trace-id': '00-****', 'X-Timestamp': '175194****.952', 'Via': 'cache8.cn6540[129,0]', 'Timing-Allow-Origin': '*', 'EagleId': '6ae3651c1751942941849****'}, body: b'{"code":0,"expire":4340,"msg":"ok","tenant_access_token":"t-g10478a*******CSC3YVY"}'
    INFO set feishu tenant access token expires in: 4340

Appendix

Obtain the API server address

  1. Log on to the RAGFlow page.

  2. In the left-side navigation pane, click API.

  3. Obtain the API server address.

Obtain the API key

  1. Log on to the RAGFlow page.

  2. In the left-side navigation pane, click API.

  3. To the right of RAGFlow API, click API KEY.

  4. In the API KEY dialog box, click Create New Key.

  5. Click image to copy the token.

Obtain the knowledge base ID

  1. Log on to the RAGFlow page.

  2. On the Knowledge Base page, click the target knowledge base.

  3. In the URL of the current page, copy the knowledge base ID.

    Note

    The knowledge base ID is the value that follows id=.