Skip to main content

Create a Custom Connector

Step 1: Copy the Sample Connector

Begin by copying a sample connector to serve as a template for your custom connector. This step ensures that you have a solid foundation and proper structure to start with.

  1. Clone the chosen sample connector into your development environment:

    cd path/to/your/development/folder
    git clone https://github.com/PromptMixerDev/prompt-mixer-sample-connector.git your-connector-name

Step 2: Update the Connector's Main Script

The main.js file contains the core logic of your connector. Update this file to add your specific functionality.

  1. Navigate to the connector's directory:

    cd your-connector-name
  2. Open main.js in your code editor.

  3. Modify the file to add your custom logic, adjusting API interactions, data processing, and error handling as needed.

Step 3: Customize the Connector Configuration

The configuration for your connector, including its name, associated models, and any specific settings, is defined in a config.js file. Here, you also define the connector's properties and descriptions.

  1. Create or update the config.js file in your connector's directory:

    touch config.js # If it doesn't already exist
  2. Open config.js in your code editor and define your connector's configuration. Use the structure provided below as a guide, customizing it to fit your connector:

    export const config = {
    connectorName: 'Your Connector Name',
    models: ['model-name'],
    properties: [
    { id: 'property-id', name: 'Property Name', value: defaultValue, type: 'data-type' },
    ],
    settings: [
    { id: 'SETTING_ID', name: 'Setting Name', value: 'default_value', type: 'string' },
    ],
    description: 'Description of what your connector does and its purpose.',
    author: 'Author or Organization Name',
    iconBase64: 'data:image/svg+xml;base64,',
    };
    • connectorName: The name of your connector.
    • models: An array of model names your connector will use.
    • properties: (Optional) A list of properties specific to the models, including their ID, name, default value, and type.
    • settings: (Optional) Configuration settings for the connector, such as API keys or other credentials.
    • description: A brief description of your connector's functionality.
  3. Save your changes to config.js.

Step 4: Revise the Manifest File

Update the manifest.json file to accurately describe your connector and its capabilities.

  1. Open manifest.json in your code editor.

  2. Modify the file with your connector's details, such as its unique identifier, name, description, and version.

  3. Save your changes.

Step 5: Manage Dependencies

Install any necessary external libraries or packages your connector depends on.

  1. In your connector's directory, use npm or yarn to add dependencies:

    npm install package-name

    Replace package-name with the actual names of the dependencies required for your connector.

Step 6: Test Your Connector

Thoroughly test your connector to ensure it functions as expected in various scenarios.

  1. Implement unit tests for critical functionality, especially around data processing and external API calls.

  2. Manually test your connector in its intended environment to identify any issues not covered by automated tests.

Step 7: Deploy Your Connector

Finalize your connector for deployment, ensuring it is ready for use in its target environment.

  1. Follow the specific deployment procedures required for your connector, which may involve packaging or publishing to a repository.

  2. Document any necessary setup or configuration steps for users.

By following these steps, you will have successfully created, configured, and deployed a custom connector with specific models, properties, and settings, ready for integration into its intended environment.