Skip to content
SDK of the Clova CEK for Node.js
TypeScript
Branch: master
Clone or download
Latest commit 69a9bca Jul 31, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
examples/echo Initial commit Jul 12, 2018
src
test
.editorconfig
.gitignore Initial commit Jul 12, 2018
.travis.yml Update travis ci yml file Jul 31, 2019
CODE_OF_CONDUCT.md
CONTRIBUTING.md Update CONTRIBUTING.md Aug 29, 2018
LICENSE Initial commit Jul 12, 2018
OSS_NOTICE.md
README.md Add build status badge. Aug 27, 2018
package-lock.json
package.json Merge branch 'master' into update-typescript Jul 31, 2019
rollup.config.ts
tsconfig.json Initial commit Jul 12, 2018
tslint.json

README.md

Clova CEK SDK Nodejs

Build Status

Getting Started

Installing

$ npm install @line/clova-cek-sdk-nodejs

Example

const clova = require('@line/clova-cek-sdk-nodejs');
const express = require('express');
const bodyParser = require('body-parser');

const clovaSkillHandler = clova.Client
  .configureSkill()
  .onLaunchRequest(responseHelper => {
    responseHelper.setSimpleSpeech({
      lang: 'ja',
      type: 'PlainText',
      value: 'おはよう',
    });
  })
  .onIntentRequest(async responseHelper => {
    const intent = responseHelper.getIntentName();
    const sessionId = responseHelper.getSessionId();

    switch (intent) {
      case 'Clova.YesIntent':
        // Build speechObject directly for response
        responseHelper.setSimpleSpeech({
          lang: 'ja',
          type: 'PlainText',
          value: 'はいはい',
        });
        break;
      case 'Clova.NoIntent':
        // Or build speechObject with SpeechBuilder for response
        responseHelper.setSimpleSpeech(
          clova.SpeechBuilder.createSpeechText('いえいえ')
        );
        break;
    }
  })
  .onSessionEndedRequest(responseHelper => {
    const sessionId = responseHelper.getSessionId();

    // Do something on session end
  })
  .handle();

const app = new express();
const clovaMiddleware = clova.Middleware({ applicationId: "YOUR_APPLICATION_ID" });
// Use `clovaMiddleware` if you want to verify signature and applicationId.
// Please note `applicationId` is required when using this middleware.
app.post('/clova', clovaMiddleware, clovaSkillHandler);

// Or you can simply use `bodyParser.json()` to accept any request without verifying, e.g.,
app.post('/clova', bodyParser.json(), clovaSkillHandler);

NOTE: async/await is part of ECMAScript 2017 and is not supported some browsers, so use with caution.

Documentation

Contributing

Please check CONTRIBUTING.

npm scripts

  • npm test: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
You can’t perform that action at this time.