npm install npm install nodemon
You will need
- Your WABA phone number that has been approved by tyntec
- A testing customer WhatsApp
- An IBM Cloud account (A free Lite account is enough for 10 000 messages per month, with 5 minutes allowed for session inactivity.)
- Your Conversations Inbox API key provided by tyntec (contact tyntec support if you don't have it)
- An Automatic Assistant for CMD set up by tyntec (contact tyntec support if you don't have it)
- Postman
- An ngrok account with the binary installed and authorized
- A Node.js and your favourite text editor or IDE with JavaScript highlighting
Step One: Get your integration app ready
For your quick start with integrations, we’ve prepared a sample integration app. Let’s have a look at what the code does. Notice the code in the following files:
- server.js does basic management, provides endpoints, and binds the logic together.
- watsonHandler.js handles communication with Watson Assistant API and creates sessions with the Watson Assistant.
- tyntecHandler.js forwards messages from the Watson Assistant to the given WhatsApp conversation via the CMD API.
- config.js takes responsibility for app configuration.
- cacheState.js caches a session for the Watson Assistant.
Let’s just quickly get your app running:
1. Clone the api-sample repository and go to the chat-integrations/watson directory.
2. Install dependencies (and the nodemon module if you don’t have it yet):
path/to/ngrok ngrok http 3000
4. Copy the tunnel URL (The URL looks like http://843fc8776770.ngrok.io).
Note: This setup is suitable only for development. For production use, you have to deploy your app properly!
Step Two: Subscribe your webhook in the Inbox
Let the Inbox know where to deliver WhatsApp messages from customers. You’re going to subscribe your webhook via an API call in Postman.
- From the chat-integrations directory, import the CMD.postman_collection.json into Postman.
- Authorize Postman with your CMD API key and your WABA number. Right-click the collection and select Edit. Then go to Variables and set the apiKey variable to your CMD API key. Set also the wabaNumber variable to your WABA number.
- Let’s set up the webhook! Open the Set Webhook request and change the URL in body to the /message endpoint on your server (for example https://843fc8776770.ngrok.io/message). This request will subscribe your URL to incoming message events.

Step Three: Configure your IBM Watson Assistant
You need to set up your IBM Watson Assistant. Then, you train Watson with Intents and set responses to these intents using Dialog. The combination of Intents and Dialogs is called a Dialog Skill.
1. Login into your IBM cloud account and click on the Create Resource button.
2. Search for Watson Assistant and open the Watson Assistant page.








Tip: You can always test the Assistant with the Try it button.



Select your Intent in the If assistant recognizes field. Then you can write down Watson's responses. If you find it fitting, change the response variation: Random makes Watson use only one of the lines, sequential sends all lines as individual messages, and multiline sends a single large message with all the lines.
12. Now your Watson Assistant is set up, you just need its Assistant ID. Go back to the Assistant page, click on the three dots to open Settings and select Settings.


Step Four: Configure and run your app
Now you just need to finish configuring your app.
1. Copy the file .env-example to .env and set environment variables in .env:
- ASSISTANT_ID -- ID of your Watson Assistant
- WATSON_API_KEY -- API key for your Watson Assistant account
- WATSON_URL -- URL of your Watson Assistant
- WABA_NUMBER -- your WABA number in the international format without the leading +/00
- CMD_API_KEY -- your API key from tyntec to authenticate calls to CMD API
2. Start the app in another terminal:
nodemon app.js

More?
For example, you may want to automate your integration further:
- Refresh your session
The sample application doesn't refresh Session ID automatically. A session is usually dropped due to inactivity (the session limit is 5 minutes for Lite plans). Look at the official documentation to find how to change the settings.
If you want to stick with a Lite plan, you can extend the app to call for a new Session ID with a new conversation, or to watch session expiration by saving a timestamp of the last session retrieval. -
Train your Assistant to answer more intents, add new dialog skills, or annotate semantic entities.