Skip to main content
All CollectionsCustom Plugins
Creating a POST Route Custom Plugin in TeamAI
Creating a POST Route Custom Plugin in TeamAI

Create POST route custom plugins in TeamAI to send data to external APIs and expand your AI's capabilities.

Moiz avatar
Written by Moiz
Updated over a week ago

The POST route custom plugin in TeamAI allows your AI model or assistant to communicate with external APIs using the HTTP POST method. By configuring this plugin, you can enable your AI to send data to various endpoints, expanding its capabilities and allowing it to interact with a wide range of services.

Creating a POST Route Custom Plugin

To create a POST route custom plugin, follow these steps:

  1. Navigate to the "Custom plugins" section in the left sidebar of your TeamAI dashboard.

  2. Click on the "Create plugin" button.

  3. Name your plugin and click "Create."

  4. In the "Endpoint" field, enter the URL of the API endpoint you want to connect to.

  5. In the "Method" dropdown, select "POST."

Configuring Query Parameters and Headers

The POST route custom plugin supports both query parameters and headers, just like the GET route plugin. Query parameters are key-value pairs appended to the end of the API URL, while headers provide additional information about the request.

To add query parameters or headers:

  1. In the plugin configuration, locate the "Query Parameters" or "Headers" section.

  2. Click on the "Add Parameter" or "Add Header" button.

  3. Enter the key and value for the parameter or header.

  4. Click "Save" to apply the changes.

Configuring the Payload

In addition to query parameters and headers, the POST route custom plugin also includes a "Payload" field. The payload is the data sent in the body of the POST request.

To add properties to the payload:

  1. In the plugin configuration, locate the "Payload" section.

  2. Click on the "Add Property" button.

  3. Enter the key and value for the property.

  4. Click "Save" to add the property to the payload.

Using Dynamic Parameters (Variables)

Dynamic parameters, or variables, allow you to create flexible and reusable plugins. By defining variables, you can enable the AI model to input values based on the user's query when the plugin is toggled.

To create a new parameter:

  1. In the plugin configuration, click on the "Add property" button in the "Parameters" section.

  2. Enter a meaningful name and description for the parameter, as these will be used by the AI model.

  3. Select the appropriate type for the parameter (e.g., string, number, boolean).

  4. Click "Save" to add the parameter.

To use a dynamic parameter in query parameters, headers, or payload, simply reference the variable name wrapped in double curly braces, like this: {{variableName}}.

Example: Using Dynamic Parameters

Let's say you've created a dynamic parameter called userId. You can use this parameter in the following ways:

  • In a query parameter:

    • Key: userId

    • Value: {{userId}}

  • In a header:

    • Key: X-User-Id

    • Value: {{userId}}

  • In the payload:

    • Key: user

    • Value: { "id": {{userId}} }

When the AI model processes a user's query with this plugin toggled, it will attempt to input a value for the userId parameter based on the context of the query.

Setting Types for Payload

Currently, there is no built-in way to set static payloads with different types other than strings in TeamAI. However, you can create a parameter with the desired types and set it as the payload.

To create a parameter with types:

  1. In the plugin configuration, click on the "Add property" button in the "Parameters" section.

  2. Enter a meaningful name and description for the parameter.

  3. Select the appropriate type for the parameter (e.g., object, array).

  4. Define the structure of the parameter using the "Properties" field.

  5. Click "Save" to add the parameter.

To set the parameter as the payload:

  1. In the "Payload" section, click on the "Add Property" button.

  2. Enter the key for the payload and reference the parameter using double curly braces, like this: {{parameterName}}.

  3. Click "Save" to set the parameter as the payload.

Please note that setting static payloads with different types is not currently supported in TeamAI.

Conclusion

The POST route custom plugin in TeamAI is a powerful tool for enabling your AI model or assistant to send data to external APIs. By configuring query parameters, headers, and the payload, and using dynamic parameters, you can create versatile plugins that expand your AI's capabilities.

Feel free to experiment with different configurations and test your plugin with various user queries to ensure it functions as expected. With the POST route custom plugin, you can unlock new possibilities for your AI model and provide even more value to your users.

Did this answer your question?