Skip to main content

API

Introduction

The API tool unlocks a world of possibilities by connecting your AI Assistant to various external services and data sources through APIs (Application Programming Interfaces). Whether you're fetching product details, submitting form data, or retrieving real-time information, this tool empowers your assistant to perform tasks across a multitude of platforms seamlessly. This guide will walk you through setting up and utilizing the API tool effectively.

Configuration Overview

Before diving into the setup, here's a quick rundown of the key components you'll configure:

  • API Url: The endpoint your assistant will communicate with.
  • HTTP Method: Defines the type of request (GET, POST, DELETE) to interact with the API.
  • Request Parameters: The data your assistant will send to the API Url.
  • HTTP Headers: Additional headers required by the API for requests (e.g., Content-Type, Authentication).
  • Output Formatter: Specify which parts of the API response are relevant to your assistant's tasks. Here is a quick guide how to create your JSON Paths.

Setting Up the API Tool

1. API Url

Enter the full URL of the API endpoint your assistant will access. This is the address where your request will be sent.

2. Selecting HTTP Method

Choose the method that matches the API's requirements:

  • GET for retrieving information,
  • POST for sending data,
  • DELETE for removing data.

3. Configuring Request Parameters

Define the data your assistant will send. For each parameter, specify:

  • Name (e.g., product_name): The key or identifier used by the API.
  • Description (e.g., "The name of the product for the search"): Helps the assistant understand how to use this parameter.
  • Type (Text, Number, Decimal, Boolean, List Of Texts, List Of Numbers): Ensures data is formatted correctly for the API.
  • Default Value: A fallback value if the user doesn't provide one.
  • Is Optional?: Marks the parameter as optional or mandatory.
  • Autofill by AI Assistant: Allows the assistant to automatically fill this parameter based on user input.

4. Adding HTTP Headers

Some APIs require specific headers for authentication or data format. Add these as needed, such as Content-Type: application/json.

5. Output Formatter

If your API response includes sensitive or unnecessary information, use the output formatter to specify which JSON fields the assistant should consider.

Practical Example: Fetching Product Details

Let's say you run an online store and want your assistant to fetch product details on command. Here’s a simple setup:

  • API Url: https://api.example.com/products/details
  • HTTP Method: GET
  • Request Parameters:
    • Name: product_id
    • Description: "The unique identifier for the product"
    • Type: Number
    • Is Optional?: No
    • Autofill by AI Assistant: Yes
  • HTTP Headers: None required for this example.
  • Output Formatter: Specify paths like $.product_name and $.price to extract only the product name and price from the response.

Best Practices

  • Securely Handle Sensitive Data: Use headers for authentication tokens, but ensure they are securely managed.
  • Test Your Configuration: Before going live, test the API tool to ensure it interacts with the API as expected.
  • Do not expose all response to AI Assistant: Use Output Formatters to expose only the necessary data to AI Assistant in order to solve the task, otherwise it could discolse sensitive information to users.

Conclusion

Integrating APIs with your AI Assistant can significantly enhance its capabilities, making it a more valuable tool for you and your users. By following the steps outlined in this guide, you'll be well on your way to unlocking the full potential of your assistant through the power of APIs.