API plugin

Updated at:

This document describes how to create a new API plugin and perform API debugging.

Overview

When you configure nodes in process management, you may need to call APIs.

image.png

Procedure

Creating an API

  1. In the bot workspace, navigate to Knowledge Base > API Plugin and click Create API. In the dialog that opens, configure the API's settings:

  • Service name: The name must follow standard variable naming conventions (such as snake_case or camelCase) and contain only English characters. For example: income_proof or incomeProof.

  • Service description: Include brief details about its input and output parameters, such as "queries weather data based on location". Add any specific requirements, for example, "either the city or zip_code parameter is required, but not both".

  • User prompt for long API calls: For API calls that might take a long time, define a message to show the user, such as "Querying data for you...".

  • API configuration: Configure the API's interface, header, input parameters, output parameters, signature authentication, and service mocking.

    • Interface configuration: Select the request method and enter the API's URL.image.png

    • Header parameters: Enter the header parameters.image.png

    • Input parameters: For each parameter, define its name, type, value source, whether it is required, and parameter description.

      • Parameter: The parameter name must follow the same conventions as the service name and can only contain English characters.

      • Type: Available types include string, number, boolean, and list.

        Note

        string: Text values, such as names, descriptions, IDs, and status codes.

        number: Numeric values (integers or floating-point numbers), such as counts, amounts, and timestamps.

        boolean: Represents true or false. It is used to represent switches, statuses, success or failure, etc.

        list: An ordered collection (array) of elements. Common use cases include storing list items, multi-select results, tag sets, and arrays of child objects. Elements can be accessed by their index.

      • Value source: Options are "Model Recognition" and "passthrough parameter". A passthrough parameter is not sent to the model for recognition.

      • Required: Specifies if the parameter is mandatory. Each API should have at least one required parameter. The chatbot will not ask for optional parameters but will use them if provided by the user.

      • Parameter description: Similar to the service description, this should include a display name, a format description, and an example.image.png

      Note

      For other data types, such as enums, define them using the parameter description. The following is an example of an input parameter definition:

      image.png

    • Output parameters: Define these using the same standards as input parameters.

      • Define the structure of the output. The available formats are object, list, string, number, and boolean.

        Note

        object: A set of key-value pairs.

        list: An ordered collection of elements.

      • Mock value: Use this field to set a fixed API response when a real request URL is unavailable. This requires you to enable the service mocking feature.image.png

    • Signature authentication: To secure HTTP and HTTPS services, you can enable signature calculation in the service configuration. When this feature is enabled, the service computes a signature for each API call and adds it to the request header.

    • For instructions, see the Signature Calculation Guide.

    • Service mocking: If you use a mock value for an output parameter, you must enable service mocking.

      Note

      To apply the mock value, you must enable its switch in the dialog debugging window. This setting then overrides the real URL request. For example:image.png

  1. After you complete the configuration, click OK. The following figure shows the page that appears after the API configuration is complete.

image.png

API debugging

After configuring the API plugin, use the debugging feature to verify that the chatbot can call the API plugin.

  1. Click the "Debug" button to open the API Debugging window.

image.png

2. Enter the "Input Parameter" information and click "Start Debugging". If the debug succeeds and returns the correct information, the interface configuration is correct.

image.png