File Import Tools (Flat Data)
When a user wants to import a file (CSV, Excel, TSV, etc.) into Improvado, use these tools.
Routing rules:
- If the user mentions SFTP → use the Managed SFTP Workflow directly (datasourceName: "managed_sftp")
- If the user mentions S3 or AWS S3 → use the Managed S3 Workflow directly (datasourceName: "managed_s3")
- If the user mentions email import → use the Email Import Workflow (datasourceName: "email_file_import")
- If the user uploads a file or says file import → use the File Import Workflow (datasourceName: "file_import")
- If unclear, ask which method they prefer: file upload, email, SFTP, or S3
Available Tools
- getConnectionsTool (existing) - Get the connection_id:
getConnectionsTool({ datasourceName: "file_import" })
- uploadFlatDataFileTool - Upload the file to DTS managed storage
- ALWAYS pass the attachment URL as fileUrl — do NOT base64-encode file content
- Handles multipart upload and antivirus scanning automatically
- Returns file_path (used in all subsequent calls), file_name, and file_size
- discoverFileFieldsTool - Discover field definitions and data sample from the uploaded file
- Pass the connection_id from step 1 and file_path from step 2
- Returns inferred field names, types, and data_sample (first rows of data)
- generateFlatDataSampleTool - Generate a data preview with confirmed field definitions
- Use after the user confirms or adjusts the discovered schema
- createFlatDataExtractTool - Create the extract with the final configuration
- Creates a persistent extract that stores the imported data
- data_table_title: Propose a name based on the file name (e.g. "report.csv" → "report_csv_data"). Ask the user to confirm.
- uploadNewFileToExtractTool - Upload a new file to an existing extract/data table
- Use when the user wants to add/replace data in an existing data table
- Requires: extract_id + file details from uploadFlatDataFileTool
- Backend automatically triggers data processing
- previewEmailImportAddressTool - Preview the email address for email-based file import
- Shows what email address will be generated for a given data_table_title
- The actual email is activated after the extract is created
- createConnectionTool (existing) - Create a connection if none exists
- For managed SFTP:
createConnectionTool({ data_source_name: "managed_sftp", auth_id: "login_password", params: { connection_name: "<name>" } })
- For managed S3:
createConnectionTool({ data_source_name: "managed_s3", auth_id: "login_password", params: { connection_name: "<name>" } })
- getManagedConnectionCredentialsTool - Fetch credentials for a managed SFTP or S3 connection
- Returns: host, port, login, password
- Use after getting/creating a managed_sftp or managed_s3 connection to show credentials to the user
File Import Workflow
Call getConnectionsTool({ datasourceName: "file_import" }) to get the connection_id
Call uploadFlatDataFileTool with fileUrl (from chat attachment) → get filepath
Call discoverFileFieldsTool with connection_id + filepath → get fields + data_sample
Analyze the data_sample and discovered fields:
- Detect the file format and encoding
- Identify if any top rows should be skipped (header offset)
- For each field, determine: Type (Text, Number, DateKey), Is key (True/False - Fields used to merge new & existing data), and any skip rules
Call generateFlatDataSampleTool with the fields for a data preview
Important: Present the proposed schema to the user as a table with columns: Field Name, Type, Is key (dimension or property/metric), Sample Values. Propose a Data Table name based on the file name and Write Policy, then ask for confirmation.
Example:
| Field Name | Type | Is Key | Sample Values |
|----------------|--------|--------|------------------------|
| date | Date | Yes | 2024-01-15, 2024-01-16 |
| campaign_name | Text | Yes | Brand Campaign, Promo |
| impressions | Number | No | 15234, 8921 |
| spend | Number | No | 150.50, 89.20 |
Data Table Name: facebook_ads_performance
Write Policy: Upsert (whole data)
After the user confirms (or edits), call createFlatDataExtractTool with the confirmed configuration
After extract creation succeeds, provide the user with a link to the created extract:
| Resource | Link |
|----------|-----------------------------------------------------------------------------------------------|
| Extract | {platform_host}/info_connector/overview/{connection_id}/{extract_id}?workspace={workspace_id} |
Example: https://report.improvado.io/info_connector/overview/19417/1785798?workspace=12345
Use connection_id from step 1, extract_id from the createFlatDataExtractTool response, and the current workspace ID.
Upload to Existing Data Table Workflow
- Upload file with
uploadFlatDataFileTool → get file_path, file_name, file_size
- Call
uploadNewFileToExtractTool with the extract_id and file details
Email Import Workflow
The same File Import Workflow applies, except:
- Use
getConnectionsTool({ datasourceName: "email_file_import" }) instead of "file_import"
- After proposing a data_table_title, call
previewEmailImportAddressTool to show the user the email address
- After
createFlatDataExtractTool succeeds, the email becomes active — users can send files to it
What is Managed SFTP / Managed S3?
Managed SFTP and Managed S3 are Improvado-hosted file ingestion endpoints. Improvado provisions and owns the SFTP/S3 server — the user does NOT provide their own server.
Flow: Improvado creates a connection → provides credentials (host, port, login, password) → the user uploads files to Improvado's server using those credentials → Improvado automatically ingests the data.
NEVER describe this as "connecting to the user's SFTP/S3 server" — it is the opposite: the user connects to our server.
Managed SFTP Workflow (step by step — follow this order strictly)
IMPORTANT: Do NOT ask for data table name, file columns, or schema upfront. Follow these steps IN ORDER:
Step 1 — Connection
- Call
getConnectionsTool({ datasourceName: "managed_sftp" }) to check for existing connections.
- If a connection exists, use it. If not, ask the user for a connection name, then create one:
createConnectionTool({ data_source_name: "managed_sftp", auth_id: "login_password", params: { connection_name: "<name>" } })
Step 2 — Sample file
Ask the user to upload a sample file (CSV/Excel/TSV) via chat attachment. This is required to discover the schema.
Step 3 — File Import Workflow
Follow the standard File Import Workflow (upload → discover fields → confirm schema → create extract).
Use the connection_id from Step 1.
Step 4 — Show credentials
After createFlatDataExtractTool succeeds:
Call getManagedConnectionCredentialsTool({ data_source_name: "managed_sftp", connection_id }) to fetch SFTP credentials
Show the credentials and folder name to the user. The folder name is the snake_case version of the data_table_title (e.g. "My Sales Report" → my_sales_report).
Password display: mask the password with asterisks and wrap it in a <details> tag so the user can click to reveal:
<details><summary>••••••••</summary>actual_password</details>
Example:
**SFTP Connection Credentials (Improvado-hosted):**
| Field | Value |
|-------------|--------------------------------|
| Host | ftp.tools.improvado.io |
| Port | 2022 |
| Login | managed_1_26_my_data |
| Password | <details><summary>••••••••</summary>ysUXysurE9TGhSvTAc4k</details> |
| Folder | my_sales_report |
| Resource | Link |
|----------|-----------------------------------------------------------------------------------------------|
| Extract | {platform_host}/info_connector/overview/{connection_id}/{extract_id}?workspace={workspace_id} |
Upload your files to the folder above via SFTP using these credentials. Improvado will automatically process incoming files.
Managed S3 Workflow (step by step — follow this order strictly)
Same steps as Managed SFTP Workflow above, except:
- Use
getConnectionsTool({ datasourceName: "managed_s3" }) instead of "managed_sftp"
- Use
createConnectionTool({ data_source_name: "managed_s3", auth_id: "login_password", params: { connection_name: "<name>" } }) if no connection exists
- Use
getManagedConnectionCredentialsTool({ data_source_name: "managed_s3", connection_id }) to fetch S3 credentials
- S3 credentials differ from SFTP — expect fields like bucket, access key, and secret key instead of host/port/username/password. Display whatever fields the API returns.
Important Rules
- Write Policy: The default write policy is
{ method: "upsert", scope: "whole_data" } which replaces all data on each file upload.
- NEVER try to base64-encode or stream file content. Always use the fileUrl from the chat attachment.
- ALWAYS ask for confirmation before creating the extract — present the schema table and proposed name first.
1---2name: flat-data-file-import3description: File import workflow - upload CSV/Excel/TSV files, set up email-based, managed SFTP, or managed S3 file import into Improvado4---56## File Import Tools (Flat Data)78When a user wants to import a file (CSV, Excel, TSV, etc.) into Improvado, use these tools.910**Routing rules:**11- If the user mentions **SFTP** → use the **Managed SFTP Workflow** directly (datasourceName: "managed_sftp")12- If the user mentions **S3** or **AWS S3** → use the **Managed S3 Workflow** directly (datasourceName: "managed_s3")13- If the user mentions **email import** → use the **Email Import Workflow** (datasourceName: "email_file_import")14- If the user **uploads a file** or says **file import** → use the **File Import Workflow** (datasourceName: "file_import")15- If unclear, ask which method they prefer: file upload, email, SFTP, or S31617### Available Tools18191. **getConnectionsTool** (existing) - Get the connection_id: `getConnectionsTool({ datasourceName: "file_import" })`202. **uploadFlatDataFileTool** - Upload the file to DTS managed storage21 - **ALWAYS pass the attachment URL as fileUrl** — do NOT base64-encode file content22 - Handles multipart upload and antivirus scanning automatically23 - Returns file_path (used in all subsequent calls), file_name, and file_size243. **discoverFileFieldsTool** - Discover field definitions and data sample from the uploaded file25 - Pass the connection_id from step 1 and file_path from step 226 - Returns inferred field names, types, and data_sample (first rows of data)274. **generateFlatDataSampleTool** - Generate a data preview with confirmed field definitions28 - Use after the user confirms or adjusts the discovered schema295. **createFlatDataExtractTool** - Create the extract with the final configuration30 - Creates a persistent extract that stores the imported data31 - **data_table_title**: Propose a name based on the file name (e.g. "report.csv" → "report_csv_data"). Ask the user to confirm.326. **uploadNewFileToExtractTool** - Upload a new file to an existing extract/data table33 - Use when the user wants to add/replace data in an existing data table34 - Requires: extract_id + file details from uploadFlatDataFileTool35 - Backend automatically triggers data processing367. **previewEmailImportAddressTool** - Preview the email address for email-based file import37 - Shows what email address will be generated for a given data_table_title38 - The actual email is activated after the extract is created398. **createConnectionTool** (existing) - Create a connection if none exists40 - For managed SFTP: `createConnectionTool({ data_source_name: "managed_sftp", auth_id: "login_password", params: { connection_name: "<name>" } })`41 - For managed S3: `createConnectionTool({ data_source_name: "managed_s3", auth_id: "login_password", params: { connection_name: "<name>" } })`429. **getManagedConnectionCredentialsTool** - Fetch credentials for a managed SFTP or S3 connection43 - Returns: host, port, login, password44 - Use after getting/creating a managed_sftp or managed_s3 connection to show credentials to the user4546---4748## File Import Workflow49501. Call `getConnectionsTool({ datasourceName: "file_import" })` to get the connection_id512. Call `uploadFlatDataFileTool` with fileUrl (from chat attachment) → get filepath523. Call `discoverFileFieldsTool` with connection_id + filepath → get fields + data_sample534. Analyze the data_sample and discovered fields:54 - Detect the file format and encoding55 - Identify if any top rows should be skipped (header offset)56 - For each field, determine: Type (Text, Number, DateKey), Is key (True/False - Fields used to merge new & existing data), and any skip rules575. Call `generateFlatDataSampleTool` with the fields for a data preview586. **Important:** Present the proposed schema to the user as a table with columns: Field Name, Type, Is key (dimension or property/metric), Sample Values. Propose a Data Table name based on the file name and Write Policy, then ask for confirmation.5960 Example:61 ```62 | Field Name | Type | Is Key | Sample Values |63 |----------------|--------|--------|------------------------|64 | date | Date | Yes | 2024-01-15, 2024-01-16 |65 | campaign_name | Text | Yes | Brand Campaign, Promo |66 | impressions | Number | No | 15234, 8921 |67 | spend | Number | No | 150.50, 89.20 |6869 Data Table Name: facebook_ads_performance70 Write Policy: Upsert (whole data)71 ```72737. After the user confirms (or edits), call `createFlatDataExtractTool` with the confirmed configuration748. After extract creation succeeds, provide the user with a link to the created extract:7576 ```77 | Resource | Link |78 |----------|-----------------------------------------------------------------------------------------------|79 | Extract | {platform_host}/info_connector/overview/{connection_id}/{extract_id}?workspace={workspace_id} |80 ```8182 Example: `https://report.improvado.io/info_connector/overview/19417/1785798?workspace=12345`8384 Use `connection_id` from step 1, `extract_id` from the createFlatDataExtractTool response, and the current workspace ID.8586---8788## Upload to Existing Data Table Workflow89901. Upload file with `uploadFlatDataFileTool` → get file_path, file_name, file_size912. Call `uploadNewFileToExtractTool` with the extract_id and file details9293---9495## Email Import Workflow9697The same File Import Workflow applies, except:98- Use `getConnectionsTool({ datasourceName: "email_file_import" })` instead of "file_import"99- After proposing a data_table_title, call `previewEmailImportAddressTool` to show the user the email address100- After `createFlatDataExtractTool` succeeds, the email becomes active — users can send files to it101102---103104## What is Managed SFTP / Managed S3?105106Managed SFTP and Managed S3 are **Improvado-hosted** file ingestion endpoints. Improvado provisions and owns the SFTP/S3 server — the user does **NOT** provide their own server.107108Flow: Improvado creates a connection → provides credentials (host, port, login, password) → the user uploads files to **Improvado's server** using those credentials → Improvado automatically ingests the data.109110**NEVER** describe this as "connecting to the user's SFTP/S3 server" — it is the opposite: the user connects to **our** server.111112---113114## Managed SFTP Workflow (step by step — follow this order strictly)115116**IMPORTANT:** Do NOT ask for data table name, file columns, or schema upfront. Follow these steps IN ORDER:117118### Step 1 — Connection1191201. Call `getConnectionsTool({ datasourceName: "managed_sftp" })` to check for existing connections.1212. If a connection exists, use it. If not, ask the user for a connection name, then create one:122 `createConnectionTool({ data_source_name: "managed_sftp", auth_id: "login_password", params: { connection_name: "<name>" } })`123124### Step 2 — Sample file125126Ask the user to upload a sample file (CSV/Excel/TSV) via chat attachment. This is required to discover the schema.127128### Step 3 — File Import Workflow129130Follow the standard File Import Workflow (upload → discover fields → confirm schema → create extract).131Use the `connection_id` from Step 1.132133### Step 4 — Show credentials134135After `createFlatDataExtractTool` succeeds:1361371. Call `getManagedConnectionCredentialsTool({ data_source_name: "managed_sftp", connection_id })` to fetch SFTP credentials1382. Show the credentials and folder name to the user. The folder name is the snake_case version of the data_table_title (e.g. "My Sales Report" → `my_sales_report`).1393. **Password display**: mask the password with asterisks and wrap it in a `<details>` tag so the user can click to reveal:140 `<details><summary>••••••••</summary>actual_password</details>`141142 Example:143 ```144 **SFTP Connection Credentials (Improvado-hosted):**145 | Field | Value |146 |-------------|--------------------------------|147 | Host | ftp.tools.improvado.io |148 | Port | 2022 |149 | Login | managed_1_26_my_data |150 | Password | <details><summary>••••••••</summary>ysUXysurE9TGhSvTAc4k</details> |151 | Folder | my_sales_report |152153 | Resource | Link |154 |----------|-----------------------------------------------------------------------------------------------|155 | Extract | {platform_host}/info_connector/overview/{connection_id}/{extract_id}?workspace={workspace_id} |156 ```157158 Upload your files to the folder above via SFTP using these credentials. Improvado will automatically process incoming files.159160---161162## Managed S3 Workflow (step by step — follow this order strictly)163164Same steps as Managed SFTP Workflow above, except:165- Use `getConnectionsTool({ datasourceName: "managed_s3" })` instead of "managed_sftp"166- Use `createConnectionTool({ data_source_name: "managed_s3", auth_id: "login_password", params: { connection_name: "<name>" } })` if no connection exists167- Use `getManagedConnectionCredentialsTool({ data_source_name: "managed_s3", connection_id })` to fetch S3 credentials168- S3 credentials differ from SFTP — expect fields like bucket, access key, and secret key instead of host/port/username/password. Display whatever fields the API returns.169170---171172## Important Rules173174- **Write Policy:** The default write policy is `{ method: "upsert", scope: "whole_data" }` which replaces all data on each file upload.175- **NEVER** try to base64-encode or stream file content. Always use the fileUrl from the chat attachment.176- **ALWAYS** ask for confirmation before creating the extract — present the schema table and proposed name first.