Articles in this section

Import Actions in Action Builder

Actions are essential in creating workflows. They establish API connections between Forethought and external systems to retrieve or send information. This enables your AI agent to handle complex issues that would typically require human intervention.

Common use cases for Actions include:

  • Checking order status based on order ID
  • Canceling an order based on order ID
  • Resetting a user password based on email address

With the Import Actions feature, you can upload an OpenAPI/Swagger specification (in JSON format) to create multiple Actions at once. This significantly saves you time and manual effort, especially when creating many Actions.

Example of a JSON file

Below is an example of a JSON file that imports two Actions: get products and create products.

{
  "openapi": "3.0.0",
  "info": {
    "title": "Product API Demo (DummyJSON) - GET/POST Example",
    "description": "A shortened OpenAPI spec showing only GET /products and POST /products/add from the public DummyJSON test API (https://dummyjson.com/).",
    "version": "1.1.0"
  },
  "servers": [
    {
      "url": "https://dummyjson.com",
      "description": "Public DummyJSON API server"
    }
  ],
  "tags": [
    {
      "name": "Products",
      "description": "Operations related to products"
    }
  ],
  "paths": {
    "/products": {
      "get": {
        "tags": ["Products"],
        "summary": "List all products",
        "description": "Retrieves a list of all available products, potentially with pagination.",
        "operationId": "getAllProducts",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "description": "Number of products to return",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0,
              "default": 30
            }
          },
          {
            "name": "skip",
            "in": "query",
            "description": "Number of products to skip for pagination",
            "required": false,
            "schema": {
              "type": "integer",
              "format": "int32",
              "minimum": 0,
              "default": 0
            }
          },
          {
            "name": "select",
            "in": "query",
            "description": "Comma-separated list of fields to include in the response",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "title,price"
          }
        ],
        "responses": {
          "200": {
            "description": "A list of products.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProductList"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/products/add": {
      "post": {
        "tags": ["Products"],
        "summary": "Add a new product",
        "description": "Creates a new product (simulated by DummyJSON). Requires at least a 'title'. Returns the newly created product with a simulated ID.",
        "operationId": "addProduct",
        "requestBody": {
          "description": "Product data to add. Only 'title' is strictly required by the API, others are optional.",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/NewProduct"
              },
              "examples": {
                "simple": {
                  "summary": "Minimal example",
                  "value": {
                    "title": "Amazing Gadget"
                  }
                },
                "detailed": {
                  "summary": "More detailed example",
                  "value": {
                    "title": "Super Widget",
                    "description": "The best widget ever.",
                    "price": 99.99,
                    "brand": "Widgets Inc."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Product created successfully (simulated).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Product"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid input data (e.g., missing title).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "default": {
            "description": "Unexpected error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Product": {
        "type": "object",
        "properties": {
          "id": { "type": "integer", "format": "int64", "example": 1 },
          "title": { "type": "string", "example": "iPhone 9" },
          "description": {
            "type": "string",
            "example": "An apple mobile which is nothing like apple"
          },
          "price": { "type": "number", "format": "float", "example": 549 },
          "discountPercentage": {
            "type": "number",
            "format": "float",
            "example": 12.96
          },
          "rating": { "type": "number", "format": "float", "example": 4.69 },
          "stock": { "type": "integer", "example": 94 },
          "brand": { "type": "string", "example": "Apple" },
          "category": { "type": "string", "example": "smartphones" },
          "thumbnail": {
            "type": "string",
            "format": "url",
            "example": "https://cdn.dummyjson.com/product-images/1/thumbnail.jpg"
          },
          "images": {
            "type": "array",
            "items": { "type": "string", "format": "url" },
            "example": [
              "https://cdn.dummyjson.com/product-images/1/1.jpg",
              "https://cdn.dummyjson.com/product-images/1/2.jpg"
            ]
          }
        },
        "required": ["id", "title", "description", "price", "category"]
      },
      "NewProduct": {
        "type": "object",
        "properties": {
          "title": { "type": "string", "example": "BMW Pencil" },
          "description": { "type": "string", "example": "A premium pencil." },
          "price": { "type": "number", "format": "float", "example": 15.99 },
          "brand": { "type": "string", "example": "BMW" },
          "category": { "type": "string", "example": "stationery" }
        },
        "required": ["title"]
      },
      "ProductList": {
        "type": "object",
        "properties": {
          "products": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/Product" }
          },
          "total": {
            "type": "integer",
            "description": "Total number of products available",
            "example": 100
          },
          "skip": {
            "type": "integer",
            "description": "Number of products skipped",
            "example": 0
          },
          "limit": {
            "type": "integer",
            "description": "Number of products returned in this response",
            "example": 30
          }
        },
        "required": ["products", "total", "skip", "limit"]
      },
      "Error": {
        "type": "object",
        "properties": {
          "message": { "type": "string" }
        },
        "required": ["message"]
      }
    }
  }
}

How to Import Actions:

Important: Before importing, make sure that you have a file containing an OpenAPI/Swagger specification in JSON format. Currently, only JSON files are supported for this feature.

  1. Go to Solve > Action Builder > Imported Actions.
  2. In the top-right corner of the dashboard, click Import Actions.
  3. Select your JSON file. 
  4. Once the file is uploaded successfully, you can see all the Actions that were created.
  5. To make it available for use, select an Action and click Duplicate and Edit
  6. Once you’re done, click Save. The Action will be listed under the Available Actions tab and will be ready for use when creating workflows.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.

Support

  • Need help?

    Click here to submit a support request. We are here to assist you.

  • Business hours

    Monday to Friday 8am - 5pm PST excluding US holidays

  • Contact us

    support@forethought.ai