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 |
|
|
Application identity |
|
The authorization process is complex and requires additional permission configuration for Cloud Drive and wikis. |
|
|
User identity |
The authorization process is simple. It grants access to all folders without requiring separate permission configurations for Cloud Drive and wikis. |
|
Preparation
-
Sign in to the Feishu Open Platform and go to the Developer Console.
-
Click Create Custom App, configure the Name and App Description, and then click Create.
-
Click the app card to go to the app editing page.
The page opens by default.
-
On the Credentials & Basic Information page, in the App Credentials section, record the App ID and App Secret.
Procedure
For detailed instructions on Feishu operations, see the official Feishu documentation (Help Center and Developer Documentation).
Step 1: Configure access permissions
tenant_access_token
-
Sign in to the Feishu Open Platform and go to the Developer Console.
-
Click the app that you created in the Preparation section.
-
Add a bot and publish the app.
-
In the left-side navigation pane, choose .
-
On the Add by Feature tab, find the Bot card and click Add.
-
At the top of the page, click Create Version.
NoteYou can also choose in the left-side navigation pane and then click Create Version.
-
On the Version Details page, enter the Version Number and Update Description.
NoteKeep the default Bot setting for Default Mobile Capability and Default Desktop Capability.
-
Click Save.
-
In the dialog box that appears, click Confirm Release.
-
-
Configure API permissions.
-
In the left-side navigation pane, choose .
-
Click Bulk Import/Export Permissions.
-
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": [] } } -
Click Next, Confirm New Permissions.
-
Click Request to Enable.
-
-
Sign in to the Feishu client, create a new group, and add the app you created in the Preparation section as a group bot.
-
Configure access permissions for Cloud Drive and wikis.
Cloud drive permissions
-
Go to the target Cloud Drive folder.
-
On the right side of the page, click Share.
-
In the Invite Collaborators field, enter the group that you created in Step 5.
The default Reader permission is sufficient.
-
Click Send.
Wiki permissions
-
Go to the All Wikis page.
-
Hover over the target wiki and click Knowledge Base Settings.
-
Click the Member Settings tab. In the Roles & Permissions section on the Administrator tab, click Add Administrator.
-
In the dialog box that appears, add the group you created in Step 5 and click Next.
-
Click Send.
-
user_access_token
-
Sign in to the Feishu Open Platform and go to the Developer Console.
-
Click the app that you created in the Preparation section.
-
Configure API permissions.
-
In the left-side navigation pane, choose .
-
Click Bulk Import/Export Permissions.
-
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" ] } -
Click Next, Confirm New Permissions.
-
Click Request to Enable.
-
-
Configure redirect URLs.
-
In the left-side navigation pane, choose .
-
In the Redirect URL text box, enter
https://www.aliyun.com. -
Click Add next to the text box.
-
Enable the Refresh user_access_token switch.
NoteIf this switch is not visible, it is enabled by default.
-
-
Obtain the authorization code.
-
Construct the authorization page URL for Feishu.
NoteReplace
YOUR_FEISHU_CLIENT_IDin 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 -
Open the authorization page in a browser.
-
Click Authorize.
-
Obtain the authorization code (
code) from the redirect URL.NoteThe authorization code does not include code=, &, or any information that follows the & symbol.
-
Step 2: Obtain folder token and wiki ID
-
Sign in to the Feishu client.
-
Obtain the token of the folder that contains your Feishu cloud documents.
-
Go to the target folder.
-
From the address bar at the top of the page, copy the URL for the folder.
-
Obtain the token from the URL (the information after
folder/).NoteThe token does not include the ? symbol or any text that follows it.
-
-
Obtain the wiki ID.
-
Go to the All Wikis page.
-
Hover over the target wiki and click Knowledge Base Settings.
-
From the address bar at the top of the page, copy the URL for the target wiki.
-
Get the knowledge base ID from the URL (the information that follows
settings/).NoteThe wiki ID consists only of numbers and does not include the # symbol or any text that follows it.
-
Step 3: Run the KBSync program
-
Obtain the KBSync file.
NoteYou can join the DingTalk group (ID: 79690034672) and contact technical support to obtain the KBSync file.
-
Prepare the runtime environment for the KBSync program.
NoteThe KBSync program requires a Linux environment with access to the Feishu Open Platform and RAGFlow.
-
Prepare the configuration file named config.
-
Create a Linux file named config.
-
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 -
Replace the placeholder values in the config file with your values.
Important-
If a parameter is not required, leave its value empty.
-
If the
feishuCloudSpaceDirTokenandfeishuWikiSpaceIdparameters are both specified, only Feishu cloud documents and their parent folders are transmitted (only thefeishuCloudSpaceDirTokenparameter takes effect). -
Parameter
blackListhas a higher priority than parameterwhiteList.
Parameter
Required
Description
How to obtain
whiteListNo
The paths to include (whitelist) or exclude (blacklist). Paths can be folder paths in Feishu Cloud Drive or document paths within a wiki.
NoteRegular expressions are supported. Separate multiple paths with spaces.
Obtain the paths from the Feishu client.
blackListNo
sinkTypeYes
The sink type.
Set the value to
RagFlow.sourceTypeYes
The source type.
Set the value to
Feishu.ragflowUrlYes
The RAGFlow API server address.
ragflowApiKeyYes
The API key for the RAGFlow knowledge base.
ragflowDatasetIdYes
The RAGFlow knowledge base ID.
larkAppIdYes
The App ID of your Feishu app.
See Step 4 in the Preparation section.
feishuAppSecretYes
The App Secret of your Feishu app.
feishuUserAccessCodeNo
NoteYou need to pass parameters only when you access data in Feishu by using a user_access_token.
The authorization code from Feishu.
feishuCloudSpaceDirTokenNo
NoteProvide a value for only one of these two parameters.
The token of the folder that contains the Feishu cloud documents.
feishuWikiSpaceIdThe ID of the Feishu wiki.
-
-
-
Place the KBSync file and the config file in the same directory in your Linux environment.
-
In a Linux environment, execute the
./KBSync --config configcommand 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
-
In the left-side navigation pane, click API.
-
Obtain the API server address.
Obtain the API key
-
In the left-side navigation pane, click API.
-
To the right of RAGFlow API, click API KEY.
-
In the API KEY dialog box, click Create New Key.
-
Click
to copy the token.
Obtain the knowledge base ID
-
On the Knowledge Base page, click the target knowledge base.
-
In the URL of the current page, copy the knowledge base ID.
NoteThe knowledge base ID is the value that follows
id=.