Basic linkage of CLOVA Chatbot and API Gateway
    • PDF

    Basic linkage of CLOVA Chatbot and API Gateway

    • PDF

    Article Summary

    Available in Classic and VPC

    To link a chatbot with an external channel, it must first be linked with the API Gateway of NAVER Cloud Platform. First the chatbot domain and API Gateway are linked to obtain the linkage information, which will then be used for the linkage with the external channel using a webhook. API Gateway fees will be incurred, depending on the usage by domain. (1,000,000 API calls are provided free of charge in API Gateway.) It takes only a few clicks to set up the linkage, even if you don't know about API Gateway very well, so refer to this guide and make sure to store the linkage URL and secret key safely.

    Chatbot and API Gateway linkage procedure

    1. Connect the chatbot domain's invoke URL to API Gateway's endpoint
    2. Link messenger/unique channel
    Note
    • Each domain has a unique invoke URL. The invoke URLs are not disclosed immediately to external services in order to provide the secure service, and it's designed to be linked to the API Gateway of NAVER Cloud Platform instead.
    • If the chatbot and API Gateway aren't connected, then the chatbot and external channels won't be linked properly.
    • There are two methods of linking with API Gateway: automatic linkage or manual linkage. We recommend to use automatic linkage which is easy to use.

    Request API Gateway subscription

    A subscription request for the API Gateway service has to be made first in order to connect a domain's invoke URL to API Gateway. Please refer to the API Gateway Guide for more information about using API Gateway.
    The following describes how to request subscription to API Gateway.

    1. From the NAVER Cloud Platform console, click the Services > API Gateway menus, in that order.
    2. Click the [Request subscription] button.

    Automatic linkage settings

    Once the subscription request to API Gateway is completed, an API Gateway invoke URL is automatically created.
    The following describes how you can check the automatic linkage settings and copy the invoke URL.

    1. Complete subscription request to API Gateway by referring to Request API Gateway subscription.
    2. From the NAVER Cloud Platform console, click the Services > CLOVA Chatbot > Domain menus, in that order.
    3. Click the [Run builder] button of the domain you want to run the chatbot builder.
    4. From the chatbot builder's Chatbot settings > [Link messenger] tab, click the [Link] button of the messenger to link.
    5. From the linkage window, check API Gateway invoke URL under the API Gateway linkage settings item.
      chatbot-chatbot-5-1_auto_en.png
      • Click the [Modify] button to change the API Gateway invoke URL.
      • Calls are made with the invoke URL of API Gateway created automatically on webpages and mobile apps, and a unique call URL is created for each domain.
        https://mmrm1gp7p7.apigw.ntruss.com/send/beta
      • A secret key is created when calling with the invoke URL of API Gateway.
    6. Copy the API Gateway invoke URL and secret key and store them separately.

    Manual linkage settings

    When setting manual linkage, request subscription to API Gateway and follow the steps below to create an API.

    1. Create API
    2. Create Stages API
    3. Deploy API
    4. Copy the chatbot's invoke URL

    Create API

    The following describes how to create an API in API Gateway.

    1. From the NAVER Cloud Platform console, click the Services > API Gateway > My products menus, in that order.
    2. Click the [Create product] button.
    3. Enter information in the product creation window, and then click the [Create product] button.
    4. Click the APIs of the created project.
      chatbot-chatbot-5-1_api01_en
    5. Go to the API creation page, and then click the [Create API] button.
    6. Select Import from Swagger from the API creation page and enter the API name.
    7. Upload the "chatbot_messenger_swagger.json" file to the [Swagger JSON] tab of Import from Swagger.
      chatbot-chatbot-5-1_api02_en
      • The file can be downloaded from the chatbot builder's Link messenger window. From the Link messenger window, open API Gateway manual linkage, and click the [Download] button of API Gateway configuration.
        chatbot-chatbot-5-1_api03_en
    8. Click the [Create API] button.
    9. Create Stages API by referring to Create Stages API.

    Create Stages API

    The following describes how to create Stages API.

    1. Click the [Stages] tab > [Create stage] button.
      chatbot-chatbot-5-1_stagesapi01_en
    2. Enter the stage name, and select the endpoint domain as custom.
    3. Copy the invoke URL from the chatbot and paste it to the endpoint domain field.
      chatbot-chatbot-5-1_stagesapi03_en
      • For how to copy the invoke URL, refer to Automatic linkage settings
      • To link with messengers, copy the invoke URL for the created stage and store it separately.
    4. Click the [Create] button.
    5. Deploy the API, by referring to Deploy API.

    Deploy API

    The following describes how to deploy an API.

    1. Click the [Resources] tab, and click the [Deploy API] button at the top.
      chatbot-chatbot-5-1_apirelease01_en
    2. When the API deployment window appears, specify the stage to deploy, and enter the name and description of the stage.
    3. Click the [Add] button to deploy the created API.
      • Copy the invoke URL in the [Stages] tab to link with various channels.

    Copy the chatbot's invoke URL

    The following describes how to copy the chatbot's API Gateway invoke URL.

    1. From the NAVER Cloud Platform console, click the Services > CLOVA Chatbot > Domain menus, in that order.
    2. Click the [Run builder] button of the domain you want to run the chatbot builder.
    3. From the chatbot builder, click Chatbot builder > [Link messenger] tab.
    4. Click the [Link] button of the messenger you want to set up the linkage.
    5. Click the [Copy address] button to copy the API Gateway 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"
        }
      }
    }
    

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.