@cxco/whatsapp
v0.0.1
Published
DigitalCX's ready-to-go integration between DigitalCX and Twilio Whatsapp
Downloads
5
Readme
Introduction
DigitalCX's ready-to-go integration between DigitalCX and WhatsApp's messaging platform. The WhatsApp public API is currently unavailable to the public and only accessible as part of their private beta program. In order to gain access to the private WhatsApp API we suggest using Twilio's API for WhatsApp Node.js Quickstart guide. This project provides you with the web hook logic that you can expose on top of your pre-existing Express.js server.
const express = require('express')
const whatsapp = require('dcx-whatsapp')
const app = express()
app.use('/whatsapp', whatsapp({
project: {
customerKey: 'customerA',
projectKey: 'projectB',
culture: 'en',
apiKey: 'xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx',
env: 'cms'
},
sessionStorage: {
host: '127.0.0.1',
port: 6379,
password: '********'
},
messages: {
dialogOptionsOption: 'Press {optnumber} for {optvalue}',
dcxNoResponse: 'No response from DigitalCX',
applicationError: 'Something went wrong! Please contact support'
}
})
app.listen(3000)
Getting Started
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js. This module was developed using Node.js v8.12.0.
Installation is done using the npm install command:
npm i @cxco/whatsapp
Features
- Hooks into any Express.js server as Express middleware.
- Offers full support for Q&A's, events, dialogs and transactional dialogs.
- Each instance can be configured to integrate with a single customer-project-culture combination.
- Multiple instances can easily be created
Configuration
The DigitalCX WhatsApp integration offers a number of configuration options, some of them required and some of them optional. All configuration options need to be passed along wrapped in a single object and presented as the first parameter:
Options
|Parameter Name|Type|Description|Required|Example|
|:-|:-|:-|:-|:-|
|project|object|An object containing the information required to connect and authenticate your application with and to the DigitalCX engine.|yes|{"customerKey":"ckey", "projectKey":"pkey", "culture":"en", "apiKey":"api key", "env":"production" }
|
|sessionStorage|object|Redis.createClient() options to connect to your redis server in order to store the session|yes|{ host: "127.0.0.1", port: 6379, password: "********" }
|
|messages|object|An object containing the messages that can originate from within the dcx-twilio library. Each of these messages will be used either within the conversation (based on the response from DigitalCX) or when an error occurs.|yes|{ "dialogOptionsOption":"msg", "dcxNoResponse":"msg", "applicationError":"msg" }
|
Build and Test
To run the test suite, first install the dependencies, then run npm test:
npm i
npm test