Basic integrations between CLOVA Chatbot and API Gateway

Prev Next

Available in Classic and VPC

To integrate a chatbot with external channels, first integrate it with the NAVER Cloud Platform’s APIs Gateway. After linking the chatbot domain with the API Gateway and obtaining the integrations details, use those details to connect to external channels via a Webhook. API Gateway charges apply based on usage per domain. (API Gateway provides 1,000,000 APIs calls free of charge.) Even if you are not familiar with APIs Gateway, you can complete the integrations with just a few clicks. Refer to this guide and securely store the integration URL and Secret Key.

Integrations sequence for the chatbot and APIs Gateway

  1. Connect the chatbot domain’s Invoke URL to the API Gateway endpoint.
  2. Configure messenger integrations or custom channel integrations.
Note
  • Each domain has a unique Invoke URL. For secure service operation, the Invoke URL is not exposed directly to external services and is designed to be used by integrating with the NAVER Cloud Platform APIs Gateway.
  • If the chatbot is not connected to the APIs Gateway, the chatbot cannot integrate properly with external channels.
  • There are two ways to integrate with API Gateway: automatic integrations and manual integration. We recommend using automatic integrations because it is easier to use.

Subscribe to the API Gateway

To integrate the Invoke URL of a domain that uses API Gateway, you must first subscribe to the API Gateway service. For details about using API Gateway, see API Gateway user guide.
To subscribe to the API Gateway:

  1. In the NAVER Cloud Platform console, navigate to i_menu > Services > Application Services > API Gateway.
  2. Click [Subscribe to product].

Automatic integrations settings

When you subscribe to the API Gateway application, the API Gateway Invoke URL is generated automatically.
To check the automatic integrations settings and copy the Invoke URL:

  1. Complete your subscription to the API Gateway. See Subscribe to the API Gateway service.
  2. In the NAVER Cloud Platform console, navigate to i_menu > Services > AI Services > CLOVA Chatbot > Domain.
  3. Click [Run builder] of the domain you want to run the Chatbot Builder.
  4. In the Chatbot Builder, go to Chatbot Settings > [Messenger Integrations], and click [Integrate] for the messenger you want to connect.
  5. In the integrations window, check APIGW integration setting items under APIGW Invoke URL.
    chatbot-chatbot-5-1_auto_ko
    • To change the APIGW Invoke URL, click [Edit].
    • Calls from web pages and mobile apps use the automatically generated API Gateway Invoke URL, and each domain has its own unique call URL.
      Example: https://mmrm1gp7p7.apigw.ntruss.com/send
    • When you call the API Gateway Invoke URL, the system generates a Secret Key.
  6. Copy the APIGW Invoke URL and Secret Key, and store them separately.

Manual integrations setup

When you configure manual integration, create the API after you subscribe to the API Gateway, following the steps below.

  1. Create an API
  2. Create a Stages API
  3. Deploy the API
  4. Copy the chatbot Invoke URL

Create an API

To create an API in API Gateway:

  1. In the NAVER Cloud Platform console, navigate to i_menu > Services > Application Services > API Gateway > My Products.
  2. Click [Create Product],
  3. On the Create Product interface, enter the required information, then click [Create Product].
  4. Select APIs for the created project.
    chatbot-chatbot-5-1_api01_ko
  5. On the Create API page, click [Create API],
  6. On the Create API interface, select , Import from Swagger then enter an API name.
  7. In Import from Swagger, upload the chatbot_messenger_swagger.json file under [Swagger JSON] tab.
    chatbot-chatbot-5-1_api02_ko
    • Download the file from the Messenger Integrations window in the Chatbot Builder. In the Messenger Integrations window, open APIGW Manual Integrations, then click [Download] under APIGW Configuration.
      chatbot-chatbot-5-1_api03_ko
  8. Click [Create API].
  9. Create the Stages API. See Stages API creation.

Create a Stages API

To create a Stages APIs:

  1. Click [Stages] > [Create Stage].
    chatbot-chatbot-5-1_stagesapi01_ko
  2. Enter a stage name and select Custom for the endpoint domain.
  3. Copy the chatbot Invoke URL and paste it into the Endpoint domain field.
    chatbot-chatbot-5-1_stagesapi03_ko
    • For how to copy the Invoke URL, see Automatic integrations settings.
    • To integrate a messenger, copy the created stage’s Invoke URL and save it separately.
  4. Click [Create].
  5. SeeAPI deploy to deploy the API.

Deploy the API

To deploy an APIs:

  1. Click [Resources], then click [APIs deploy] at the top.
    chatbot-chatbot-5-1_apirelease01_ko
  2. When APIs deploy window appears, select the stage to deploy to, and enter the stage name and description.
  3. Click [Add] to deploy the created APIs.
    • From [Stage] tab, copy the Invoke URL to integrate with various channels.

Copy the chatbot Invoke URL

To copy the chatbot APIGW Invoke URL:

  1. In the NAVER Cloud Platform console, navigate to i_menu > Services > AI Services > CLOVA Chatbot > Domain.
  2. Click [Run builder] of the domain you want to run the Chatbot Builder.
  3. In the Chatbot Builder, select Chatbot Builder > [Messenger Integrations].
  4. Click [Integrate] for the messenger to integrate.
  5. Click [Copy address] for the APIGW Invoke URL.

chatbot_messenger_swagger.json file

The contents of the chatbot_messenger_swagger.json file are as follows.

{
  "swagger": "2.0",
  "info": {
    "description": ""
  },
  "host": "",
  "basePath": "/",
  "schemes": [ "https" ],
  "security": [ {
    "x-ncp-apigw-api-key": [ ]
  } ],
  "paths": {
    "/": {
      "get": {
        "tags": [ "messenger" ],
        "description": "",
        "consumes": [ "application/json" ],
        "produces": [ "application/json" ],
        "parameters": [ ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "x-ncp-apigw-use-body-when-formdata": false,
        "x-ncp-apigateway-filters": {
          "valid": {
            "type": "NONE"
          },
          "apiKey": {
            "required": false
          },
          "auth": {
            "platform": "NONE"
          }
        },
        "x-ncp-apigateway-endpoint": {
          "HTTP": {
            "method": "GET",
            "url": "/facebook/verify",
            "stream": false
          }
        }
      },
      "post": {
        "tags": [ "messenger" ],
        "description": "",
        "consumes": [ "application/json" ],
        "produces": [ "application/json" ],
        "parameters": [ {
          "in": "body",
          "name": "msg",
          "description": "",
          "required": true,
          "schema": {
            "$ref": "#/definitions/Empty"
          }
        } ],
        "responses": {
          "200": {
            "description": ""
          },
          "400": {
            "description": ""
          },
          "401": {
            "description": ""
          },
          "403": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        },
        "x-ncp-apigw-use-body-when-formdata": false,
        "x-ncp-apigateway-filters": {
          "valid": {
            "type": "NONE"
          },
          "apiKey": {
            "required": false
          },
          "auth": {
            "platform": "NONE"
          }
        },
        "x-ncp-apigateway-endpoint": {
          "HTTP": {
            "method": "POST",
            "url": "/message",
            "stream": false
          }
        }
      }
    },
    "/keyboard": {
      "get": {
        "tags": [ "messenger" ],
        "description": "",
        "produces": [ "application/json" ],
        "parameters": [ ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "x-ncp-apigw-use-body-when-formdata": false,
        "x-ncp-apigateway-filters": {
          "valid": {
            "type": "NONE"
          },
          "apiKey": {
            "required": false
          },
          "auth": {
            "platform": "NONE"
          }
        },
        "x-ncp-apigateway-endpoint": {
          "HTTP": {
            "method": "GET",
            "url": "/keyboard",
            "stream": false
          }
        }
      },
      "post": {
        "tags": [ "messenger" ],
        "description": "",
        "produces": [ "application/json" ],
        "parameters": [ ],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "x-ncp-apigw-use-body-when-formdata": false,
        "x-ncp-apigateway-filters": {
          "valid": {
            "type": "NONE"
          },
          "apiKey": {
            "required": false
          },
          "auth": {
            "platform": "NONE"
          }
        },
        "x-ncp-apigateway-endpoint": {
          "HTTP": {
            "method": "POST",
            "url": "/keyboard",
            "stream": false
          }
        }
      }
    },
    "/message": {
      "post": {
        "tags": [ "messenger" ],
        "description": "",
        "consumes": [ "application/json" ],
        "produces": [ "application/json" ],
        "parameters": [ {
          "in": "body",
          "name": "msg",
          "description": "",
          "required": true,
          "schema": {
            "$ref": "#/definitions/Empty"
          }
        } ],
        "responses": {
          "200": {
            "description": ""
          },
          "400": {
            "description": ""
          },
          "401": {
            "description": ""
          },
          "403": {
            "description": ""
          },
          "500": {
            "description": ""
          }
        },
        "x-ncp-apigw-use-body-when-formdata": false,
        "x-ncp-apigateway-filters": {
          "valid": {
            "type": "NONE"
          },
          "apiKey": {
            "required": false
          },
          "auth": {
            "platform": "NONE"
          }
        },
        "x-ncp-apigateway-endpoint": {
          "HTTP": {
            "method": "POST",
            "url": "/message",
            "stream": false
          }
        }
      }
    }
  },
  "securityDefinitions": {
    "x-ncp-apigw-api-key": {
      "type": "apiKey",
      "name": "x-ncp-apigw-api-key",
      "in": "header"
    }
  },
  "definitions": {
    "Empty": {
      "type": "object",
      "x-ncp-model-descption": "Default empty model"
    }
  }
}