Giter Club home page Giter Club logo

plugin-kintone-integration's Introduction

kintone integration for Twilio Flex

Twilio Flex と kintone を連携させるプラグインです。

実行イメージ

Flex画面

Studio フロー内で、発信番号から kintone 上の顧客データを検索し、データが存在する場合は顧客名を表示させます。

さらに、TaskListItem コンポーネントの下に、kintoneという文字のリンクが表示され、そこをクリックすると別タブで kintone の顧客アプリが開きます。

顧客アプリ

顧客アプリ側に登録が無い電話番号からの着信の場合は、kintone 側は顧客アプリの新規登録画面が表示されます。
このとき、クリップボードに発信番号がコピーされているので、電話番号欄への記入が簡単になります。

Flex UI のバージョン

本プラグインは、Flex UI 2.0 beta-2 で作成してありますが、Flex UI 1.32 でも動作することは確認されています。

ファイル構成

.
├── README.md
├── build
│   ├── plugin-kintone-integration.js
│   ├── plugin-kintone-integration.js.LICENSE.txt
│   └── plugin-kintone-integration.js.map
├── functions
│   ├── assets
│   │   └── logo_kintone_mark_rgb.png
│   ├── functions
│   │   └── get-customer.js
│   ├── node_modules
│   ├── package-lock.json
│   ├── package.json
│   └── readmes
│       └── blank.md
├── jest.config.js
├── node_modules
├── package-lock.json
├── package.json
├── public
│   ├── appConfig.example.js
│   └── appConfig.js
├── src
│   ├── KintoneIntegrationPlugin.tsx
│   ├── components
│   │   └── CustomTaskItem
│   │       └── CustomTaskItem.tsx
│   └── index.ts
├── tsconfig.json
├── webpack.config.js
└── webpack.dev.js

functions フォルダには、Twilio Serverless の環境があり、Twilio Functions を使って、kintone から顧客情報を取得するget-customer.jsが格納されています。
Flex Plugin は、srcフォルダの中に格納されています。

準備

kintone の準備に加えて、serverless 環境とプラグイン環境でそれぞれ準備が必要です。

kintone

kintone 側では、顧客情報(電話番号と顧客名)が格納されているアプリを用意する必要があります。
そのアプリの読み取り権限が付与されたトークンも生成しておいてください。

serverless 環境

functions/.env.sampleをコピーします。

cp functions/.env.sample functions/.env

コピーした.envファイルを編集して、以下の変数を指定してください。

Key value
KINTONE_SUB_DOMAIN kintone のサブドメイン名(https://xxxxx.cybozu.com の xxxxx の部分)
KINTONE_CUSTOMER_API_TOKEN 顧客情報アプリで生成したトークン
KINTONE_CUSTOMER_APP_ID 顧客情報アプリの ID(https://xxxxx.cybozu.com/k/NN/ の NN の部分)
KINTONE_NUMBER_FIELD_CODE アプリの電話番号フィールドのフィールドコード(例:TEL)
KINTONE_NAME_FIELD_CODE アプリの顧客名フィールドのフィールドコード(例:顧客名)

プラグイン環境

.env.sampleをコピーします。

cp .env.sample .env

コピーした.envファイルを編集して、以下の変数を指定してください。

Key value
FLEX_APP_KINTONE_SUB_DOMAIN kintone のサブドメイン名(https://xxxxx.cybozu.com の xxxxx の部分)
FLEX_APP_KINTONE_CUSTOMER_APP_ID 顧客情報アプリの ID(https://xxxxx.cybozu.com/k/NN/ の NN の部分)

デプロイ

デプロイも Serverless 環境とプラグイン環境でそれぞれ行う必要があります。

serverless 環境のデプロイ

cd functions
npm install
npm run deploy

デプロイが成功したら、プラグイン環境に戻ります。

cd ..

プラグイン環境のデプロイ

npm install
npm run deploy

プラグインについては、デプロイをした後でリリース作業も必要です。デプロイの最後に表示されたコマンドを実行するか、Flex 画面上からプラグインのリリース作業を行ってください。

Studio Flow の設定

ここまでの設定が完了したら、最後に Studio フローを使って、kintone で取得したデータを Flex に渡していきます。
作成が必要なウィジェットは 2 つです。

RUN FUNCTION ウィジェット

getCustomerという名前で RUN FUNCTION ウィジェットを作成してください。

RunFunction

Function Parameters に、以下の Key/Value を指定してください。

Key Value
from {{trigger.call.From}}

大文字小文字を間違えないようにしてください。

SEND FLEX ウィジェット

Flex に接続するウィジェットの Attributes に、以下のパラメータを入れてください。

パラメータ名
name {{widgets.getKintone.parsed.customerName}}
recordId {{widgets.getKintone.parsed.id}}

パラメータ名、値はそれぞれダブルコーテーションで囲むのを忘れないようにしてください。

SendToFlex

ライセンス情報

本プログラムのライセンスは MIT license に準じます。

plugin-kintone-integration's People

Contributors

mobilebiz avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.