Conduit Docs
  • Getting Started
    • Importing Data
    • Connecting Multiple Accounts
    • How To Invite Additional Team Members to Your Account
    • How Does the Trial Work?
    • What's a Table/Data Schema?
    • Number of Sub-Connections
    • Default Time Range for Downloading Data
    • Conduit Data Lake
    • Conduit vs Boost.Space
    • Conduit vs Reportz.io
    • Conduit vs Google Looker Studio
  • Use Cases
    • Use Case: AI-powered Text Extraction
    • Use Case: Track Ad Campaign Performance with Conduit
    • Use Case: Enhancing Project Management with Copilot
    • Use Case: Using Conduit for Financial Analysis
    • Use Case: Use ChatGPT with your data
    • Use Case: Build financial models from raw transactional data and generate P&L statements.
    • Use Case: Marketing data analytics
    • Use Case: Using data science frameworks using your data in spreadsheets Low-Code
    • Use Case: Custom Dimensions for Ad Operations
    • Use Case: Custom dimensions for E-Commerce
    • Use Case: Extract invoices from PDF
    • Use Case: Export data from SaaS applications to your spreadsheet
    • Use Case: Online store and a physical retail locations consolidated
    • Use Case: Pull data from Advertisement platforms to a spreadsheet
    • Use Case: Consolidation of data received as separate files, for example, separate Excel reports
    • Use Case: Names, IDs, SKUs normalization
    • Use Case: Integrating Conduit with a custom CRM using SSO/OAuth2
    • Use Case: Chat Bot for Your Data
    • Use Case: Display Net sales On a Dashboard by Subtracting Ad spend from Total Sales
    • Use Case: Conduit for Healthcare Applications
  • Security & Data Privacy
    • Data Retention Policy
    • How Conduit Complies with GDPR?
    • Security
  • Spreadsheets
    • Writing data to spreadsheets: Overwrite and Update
    • Using Formulas in Spreadsheets
    • The Time Range in formulas
    • The table in the spreadsheet does not start from the first line
  • Conduit for Digital Agencies
    • How to Use White Label
    • What is a Workspace and a Sub-account
    • Use Case: Creating a Dashboard for Two Clients
    • Users in Your Team vs. Sub-Accounts in Workspaces
    • Deleting a Workspace
    • How to Log Into a Workspace
    • How to Buy Additional Workspaces
    • Schedulers in Workspaces
  • Troubleshooting
    • Error codes and how to troubleshoot data-related issues
    • Google Drive Refusing To Connect
    • Why Are my Shopify stats different?
    • Facebook Integration: How to Fix the GraphMethodException Error
  • Copilot
    • Copilot Roles: Data Analyst vs AI Generalist
    • Conduit Copilot vs. ChatGPT – What's The Difference?
    • How to Tune the Copilot
    • Data Sources for Copilot
  • For Developers
    • IP Addresses of Conduit Servers
    • Create an AI Сopilot for your app
    • Manage your AI Copilot users
    • Upload CSV files to Conduit via API (Guide)
  • Integrations
    • Instagram Integration
    • Dashboard Widgets Based On a SQL Connection
    • GA4 Integration Notes
    • Salesloft Integration
    • Self-service and Manual integrations
    • Installing Google Sheets Add-On
    • Slack Integration
    • YouTube Integration
    • HubSpot Integration
    • Conduit integration for Bigcommerce
    • Xero Integration
    • Recharge integration
    • Wrike Integration
    • Zoho Integration
    • Monday.com Integration
    • ActiveCampaign Integration
    • ClickUp Integration
    • FreshSales Integration
    • Google Ads Quality Score
    • Facebook Ads Reach
    • Shopify Net Sales and Returns
    • Gorgias tickets with Spam/Deleted/Auto-Close statuses
    • Looker Studio Connector
  • Workflows
    • Workflows – Adding New Columns
    • Workflows – using the Join by Key block
    • Workflows – using the Union block
    • Workflows – using the Transpose block
    • Workflows – creating a weekly Ad Spend report
Powered by GitBook
On this page
Edit on GitHub
  1. For Developers

Create an AI Сopilot for your app

In this use case, we'll demonstrate how to integrate AI into your application. The easiest way to integrate data is through CSV file synchronization. Conduit creates a unique UI for your application, and the AI chat link obtained can be integrated as an iframe into the user interface of your product for each specific client.

You can find the repository here: https://github.com/cndt-app/copilot_saas_demo/

Step 1: Creating a Company

The first step is to create a Company for your user. This is done by sending an HTTP POST request using the Link APP authorization token.

Example of creating a Company:

To begin, obtain the authorization token by visiting: https://app.getconduit.app/auth/link_app_token/

Then, send the following CURL request to create the Company:

curl -X POST https://api.getconduit.app/link/company/ \\
     -H "Authorization: Bearer {Link_APP_Token}" \\
     -H "Content-Type: application/json" \\
     -d '{ \\
     "id": "{User_DB_ID}", \\
     "name": "User's Company", \\
     "page_enabled": true \\
     }'

Request Parameters:

{Link_APP_Token}: The Link APP authorization token obtained from the Conduit website. {User_DB_ID}: The unique identifier of the user in your database. This identifier will be used as the id for the created Company. name: The name of the Company, which will be displayed in Conduit. page_enabled: A flag indicating whether the user can independently select data sources. Set to true to enable this feature.

Example Response:

Upon successful creation of the Company, the service will return the following response:

{
  "id": "{User_DB_ID}",
  "name": "User's Company",
  "created_at": "2023-03-15T12:34:56Z",
  "link_page": {
    "url": "https://link.to/company_page",
    "enabled": true
  },
  "api_token": {
    "token": "company_specific_token",
    "expires_at": 1678898400
  }
}

Response Field Descriptions:

id: The identifier of the created Company, corresponding to the provided User_DB_ID. name: The name of the created Company. created_at: The date and time when the Company was created in ISO 8601 format. link_page: An object containing information about the Company's page. url: The link to the Company's page where the user can select data sources. enabled: The availability status of the page (enabled/disabled). api_token: An object containing information about the API token for accessing the Company. token: The Company-specific API token. expires_at: The expiration time of the token in UNIX timestamp format. Note: The token expires after 10 minutes.

Step 2: File Upload

After creating the Company and obtaining the access token, the next step is to upload a CSV file, which will be used by Copilot to create a chat. To upload the file, you need to send an HTTP POST request to the following URL

curl -X POST https://api.getconduit.app/copilot_saas/spreadsheets/upload/ \\
     -H "Authorization: Bearer {Company_Token}" \\
     -F "file=@/path/to/orders.csv"

Request Parameters:

{Company_Token}: The access token for the Company, obtained in the previous step.

file: The path to the CSV file you want to upload. In this example, the file orders.csv is used.

Example Response:

Upon successful file upload, the server will return an integer identifier for the uploaded file.

{
  "file_id": 12345
}

Response description

The returned value (12345 in this example) is a unique identifier for the uploaded file in the Conduit system. This identifier will be used in subsequent requests to reference this file.

Step 3: Metadata Description

In order for Copilot to use the uploaded file, it's necessary to provide a description of the metadata. This is done by sending an HTTP POST request.

curl -X POST https://api.getconduit.app/copilot_saas/spreadsheets/ \\
     -H "Authorization: Bearer {Company_Token}" \\
     -H "Content-Type: application/json" \\
     -d '{ \\
           "file_id": "{file_id}", \\
           "name": "name", \\
           "thousands_separator": ".", \\
           "decimal_separator": ",", \\
           "read_from_line": 1, \\
           "columns": "columns" \\
         }'

Request Parameters:

  • {file_id}: The ID of the file obtained in the upload step. Each uploaded file has a unique ID that can only be used once.

  • name: The name of the file to be displayed in the interface, for example, "Orders."

  • thousands_separator: The symbol used to separate thousands in numbers in the file. It can be a period (.) or a comma (,).

  • decimal_separator: The symbol used to separate the decimal part in numbers. It can be a period (.) or a comma (,).

  • read_from_line: The line number from which data reading starts. For example, if the first line contains headers, read_from_line should be set to 1.

  • columns: Description of the columns in the file. Each column description includes:

    • name: The column name, which should match the name in the CSV file.

    • kind: The data type, which can be DIMENSION or METRIC.

    • type: The data type in the column. For DIMENSION, valid values are STRING, DATE, DATETIME, BOOL. For METRIC, valid values are MONEY, DECIMAL, INTEGER, PERCENT.

    • agg: The aggregation method for metrics. For DIMENSION, the only valid value is UNIQ. For METRIC, valid values are SUM, COUNT, AVERAGE, MAX, MIN, FIRST.

    • is_enabled: If false, Copilot will not use this column.

    • description: An optional field that can be used to provide additional information about the column to Copilot.

Example Response:

Upon successful saving of the file and its description, the server will return a unique identifier for the saved Spreadsheet.

{
  "id": 67890
}

Response Description: The unique identifier of the saved Spreadsheet in the Conduit system. This identifier will be used in subsequent requests.

Step 4: Creating a New Copilot Chat

Once the Spreadsheet is saved, you can create a new Copilot chat. This is done by sending an HTTP POST request.

curl -X POST https://api.getconduit.app/copilot_saas/chats/ \\
     -H "Authorization: Bearer {Company_Token}" \\
     -H "Content-Type: application/json" \\
     -d '{ \\
           "name": "Chat Name", \\
           "datasets": [ \\
             {"type": "SPREADSHEET", "id": "{spreadsheet_id}"} \\
           ] \\
         }'

Request Parameters:

  • name: The name of the new chat. This name will be displayed in the user interface.

  • datasets: The list of datasets to be used in the chat. Each dataset is described by an object, which includes:

    • type: The type of dataset. For Spreadsheet, the value should be "SPREADSHEET".

    • id: The identifier of the Spreadsheet obtained after saving it.

Example Response:

Upon successful creation of the chat, the server will return the following JSON:

{
  "id": 12345,
  "name": "Chat Name",
  "url": "https://link.to/chat/iframe"
}

Response Field Descriptions:

  • id: The unique identifier of the created chat in the Conduit system. This identifier can be used for further operations with the chat.

  • name: The name of the created chat, matching the name specified in the request.

  • url: The link to the chat's iframe. This link can be embedded in your product's user interface to provide users with direct access to the Copilot chat from your application.

Getting a List of Saved Spreadsheets

To retrieve a list of all saved Spreadsheets available for the Company, you need to send an HTTP GET request.

curl -X GET https://api.getconduit.app/copilot_saas/spreadsheets/ \\
     -H "Authorization: Bearer {Company_Token}"

Request Parameters:

In this case, no parameters are passed in the URL. You only need to provide the Company's authorization token in the request headers.

Company_Token: The access token for your company, which you used to authenticate previous requests.

Example Response:

The server's response is an array of objects, each corresponding to a saved Spreadsheet.

[
  {
    "id": 12345,
    "name": "Orders",
    "created_at": "2023-03-15T12:34:56Z",
    "columns": [
      {
        "name": "Order ID",
        "kind": "DIMENSION",
        "type": "STRING",
        "is_enabled": true
      },
      ...
    ]
  },
  ...
]

Description of Fields in the Response:

Each object in the array represents a separate Spreadsheet and contains the following fields:

  • id: The unique identifier of the Spreadsheet in the Conduit system.

  • name: The name of the Spreadsheet, as specified by the user during saving.

  • created_at: The date and time when the Spreadsheet was created in ISO 8601 format.

  • columns: An array of objects describing the columns of the Spreadsheet. Each column object includes:

    • name: The name of the column as it was specified in the CSV file.

    • kind: The type of the column - DIMENSION or METRIC.

    • type: The data type in the column. For example, STRING, DATE, DATETIME, BOOL for DIMENSION, and MONEY, DECIMAL, INTEGER, PERCENT for METRIC.

    • is_enabled: Indicates whether the column is used by Copilot.

Updating a Saved Spreadsheet

To update a previously saved Spreadsheet in Conduit Copilot SaaS, you need to send an HTTP POST request to the appropriate endpoint.

curl -X POST https://api.getconduit.app/copilot_saas/spreadsheets/{spreadsheet_id}/ \\
     -H "Authorization: Bearer {Company_Token}" \\
     -H "Content-Type: application/json" \\
     -d '{ \\
           "file_id": "optional_new_file_id", \\
           "name": "Updated Spreadsheet Name", \\
           "thousands_separator": ".", \\
           "decimal_separator": ",", \\
           "read_from_line": 2, \\
           "columns": "[{column_description}]" \\
         }'

Request Parameters:

  • {spreadsheet_id}: The unique identifier of the Spreadsheet you want to update.

  • file_id: (Optional) The ID of the new uploaded file. Leave this field empty if you don't need to update the file itself, or specify the new file ID.

  • name: The new name for the Spreadsheet. This is used for display in the user interface.

  • thousands_separator: The symbol used to separate thousands in numbers. It can be a period (.) or a comma (,).

  • decimal_separator: The symbol used to separate the decimal part in numbers. It can be a period (.) or a comma (,).

  • read_from_line: The line number from which data reading starts. Useful if new headers or notes are added at the beginning of the file.

  • columns: An array describing the columns of the file. Each description includes:

    • name: The name of the column, which should match the name in the CSV file.

    • kind: The type of the column, which can be DIMENSION or METRIC.

    • type: The data type in the column. For DIMENSION, valid types are STRING, DATE, DATETIME, BOOL. For METRIC, valid types are MONEY, DECIMAL, INTEGER, PERCENT.

    • agg: The aggregation method for metrics. For DIMENSION, the only valid value is UNIQ. For METRIC, valid values are SUM, COUNT, AVERAGE, MAX, MIN, FIRST.

    • is_enabled: If false, Copilot will not use this column.

    • description: (Optional) A description of the column, which can be used to provide additional information to Copilot.

This request allows you to update the metadata and data structure of the Spreadsheet, and if necessary, the data file itself.

Retrieving Chat List

To get a list of all created Copilot chats for your company, you can send an HTTP GET request.

curl -X GET https://api.getconduit.app/copilot_saas/chats/ \\
     -H "Authorization: Bearer {Company_Token}"

Request Parameters:

  • {Company_Token}: The access token for your company, which you used to authenticate previous requests.

Example Response:

Upon successful execution of the request, the server will return a list of chats in JSON format:

[
    {
        "id": 12345,
        "name": "Chat Name 1",
        "url": "https://link.to/chat1/iframe"
    },
    {
        "id": 67890,
        "name": "Chat Name 2",
        "url": "https://link.to/chat2/iframe"
    }
    // Or more chats 
]

Description of Response Fields:

  • id: The unique identifier of the chat in the Conduit system. This identifier can be used for further operations with the chat.

  • name: The name of the chat, specified during its creation. It is displayed in the user interface.

  • url: The link to the chat's iframe. You can embed this link into your product's user interface to provide users with direct access to the Copilot chat from your application.

This list includes all chats created for your company and can be used for managing chats or integrating them into your application.

PreviousIP Addresses of Conduit ServersNextManage your AI Copilot users

Last updated 11 months ago