# Actions

Learn how to create custom actions by making one or more APIs available to your AI agent.\
\
Actions allow agents to integrate external data or interact with the real-world, such as connecting agents to databases, plugging them into your emails, or making them your shopping assistant, all through APIs.

Actions are defined using the [OpenAPI specification](https://swagger.io/specification/), which is a standard for describing APIs.

### Create a new action

**Navigate to Actions in the dashboard.** Tap the + New button.

<figure><img src="https://876323318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkVKtyRXbqQ0J4M23KTWd%2Fuploads%2FVIchs1FBOEJF11Dv0Omv%2FScreen%20Shot%202024-02-01%20at%202.34.56%20PM.png?alt=media&#x26;token=10657ebb-6e6f-4b93-888c-0cb09e48909a" alt=""><figcaption></figcaption></figure>

**Enter a valid JSON OpenAPI specification** into the Schema input.\
\
\&#xNAN;*Note:* The Authentication feature is not yet functional. This inconvenience is temporary and will become functional soon.

<figure><img src="https://876323318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkVKtyRXbqQ0J4M23KTWd%2Fuploads%2FMm0AXybOdjWAGDfalVsW%2FScreen%20Shot%202024-02-01%20at%202.36.16%20PM.png?alt=media&#x26;token=e99591a1-8fc7-4926-85f7-161c0c038178" alt=""><figcaption></figcaption></figure>

The code block below is an OpenAPI specification example that uses the Coindesk API to get the real-time price of Bitcoin.

{% code lineNumbers="true" %}

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "CoinDesk Price Index API",
    "description": "An API that provides the current prices for various cryptocurrencies and fiat currencies.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.coindesk.com"
    }
  ],
  "paths": {
    "/v1/bpi/currentprice/{symbol}.json": {
      "get": {
        "summary": "Get current price for a specified currency or cryptocurrency",
        "operationId": "getCurrentPrice",
        "parameters": [
          {
            "name": "symbol",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "The symbol for the currency or cryptocurrency to get the price for (e.g., BTC, USD, ETH)"
          }
        ],
        "responses": {
          "200": {
            "description": "Current price for the specified currency or cryptocurrency",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "time": {
                      "$ref": "#/components/schemas/Time"
                    },
                    "disclaimer": {
                      "type": "string"
                    },
                    "bpi": {
                      "type": "object",
                      "additionalProperties": {
                        "$ref": "#/components/schemas/CurrencyPrice"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Time": {
        "type": "object",
        "properties": {
          "updated": {
            "type": "string",
            "description": "Human-readable updated time"
          },
          "updatedISO": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 formatted updated time"
          },
          "updateduk": {
            "type": "string",
            "description": "UK formatted updated time"
          }
        },
        "required": ["updated", "updatedISO", "updateduk"]
      },
      "CurrencyPrice": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "The currency or cryptocurrency code"
          },
          "rate": {
            "type": "string",
            "description": "The current rate in the specified currency or for the specified cryptocurrency"
          },
          "description": {
            "type": "string",
            "description": "Description of the currency or cryptocurrency"
          },
          "rate_float": {
            "type": "number",
            "description": "The rate as a floating-point number"
          }
        },
        "required": ["code", "rate", "description", "rate_float"]
      }
    }
  }
}
```

{% endcode %}

**Tap the Save button.**

<figure><img src="https://876323318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkVKtyRXbqQ0J4M23KTWd%2Fuploads%2FBSV1MK7VIWpHcwwVRIRL%2FScreen%20Shot%202024-02-01%20at%202.36.28%20PM.png?alt=media&#x26;token=a3d93801-b5bc-4bea-9b10-4f5ce7ef5687" alt=""><figcaption></figcaption></figure>

**You should now see the custom action** you just created.\
\
\&#xNAN;*Note:* If the OpenAPI specification is invalid, the action will not appear.

<figure><img src="https://876323318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkVKtyRXbqQ0J4M23KTWd%2Fuploads%2FzORWWnMdWY5k71PMWrog%2FScreen%20Shot%202024-02-01%20at%202.36.45%20PM.png?alt=media&#x26;token=c69ff859-7d7a-4c10-83c1-37b915df3132" alt=""><figcaption></figcaption></figure>

**Test and confirm your new action works** as expected by chatting with your AI agent.

<figure><img src="https://876323318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkVKtyRXbqQ0J4M23KTWd%2Fuploads%2FBPugRoWrKmglYrSexEuO%2FScreen%20Shot%202024-02-01%20at%202.37.56%20PM.png?alt=media&#x26;token=9ce03e9e-da64-4a3f-929b-b120956e54a6" alt=""><figcaption></figcaption></figure>

### Troubleshooting

If you need help creating a new custom action, please consider joining our [Discord community](https://discord.gg/K6tCnJtVFy) for support.
