0.8.2 • Published 1 year ago

wa-chat-server-unblu v0.8.2

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

wa-chat-server-unblu

wa-chat-server-unblu is a wa-chat-server adapter for the Unblu collaboration server.

Adapter Usage

Register the Adapter

A sample initialization of the wa-chat-server (in a chat application using wa-chat-server to communicate with Watson Assistant) with a wa-chat-server-unblu adapter:

import { WAChatServer, Types } from "wa-chat-server";
import { WAChatServerUnbluAdapter } from "wa-chat-server-unblu";
import { config } from "dotenv";
config();

const server: WAChatServer = new WAChatServer((process.env as any) as Types.IWAChatServerConfig);
server.addAdapter("unblu", WAChatServerUnbluAdapter);
server.serve();

Configure the Adapter

To pass configuration into the Adapter, use the wa-chat-server naming convention. Set the following environment variables (e.g. in .env):

VariableObligatoryMeaning
adapter__unblu__unbluApiUrlYBase URL for API endpoints on Unblu Collaboration Server, up to API version (../rest/v3)
adapter__unblu__unbluApiUsernameYUnblu basic authentication Username (account is created in Unblu Web UI)
adapter__unblu__unbluApiPasswordYUnblu basic authentication Password (account is created in Unblu Web UI)
adapter__unblu__webhookApiKeyNSecret to verify sender (Unblu) of incoming webhook events - same value must be set in Unblu when registering bot); This also requires wa-chat-server configuration json_raw_body=true; If left empty, validation will not be performed
adapter__unblu__webhookSecuritySha1NIf set to true the Adapter will use SHA-1 (x-unblu-signature header) algorithm to validate webhook events instead of SHA-256 (x-unblu-signature-256 header)
adapter__unblu__messageStaggerMsNAmount in milliseconds between messages when sending multiple responses to a single request (default is 600)
adapter__unblu__fallbackMessagesNMessages to be sent in case there is a technical outage of Watson Assistant service; Multiple answers can be specified separated by semicolon (Message1;Message2;Message3)
adapter__unblu__mappingNUse this optional configuration to specifically map Watson Assistant response types to Unblu message types
import { ResponseType, Message$Type } from "wa-chat-server-unblu";

const { disambiguation, option, text } = ResponseType;
const { OptionsPost, QuickReply, TextPost } = Message$Type;

const adapter__unblu__mapping = {
    [disambiguation]: OptionsPost,
    [option]: QuickReply,
    [text]: TextPost,
}

Watson Assistant Response Types

  1. disambiguation - Disambiguation
  2. option - Options
  3. text - Text reply

Unblu Message Types

  1. OptionPost - Title message with buttons as options; One of the options must be selected; The buttons carry payload which can be different than label displayed
  2. QuickReply - Optional response buttons that can be used instead of typing the response; When using an quick reply the value sent is the same as the label
  3. TextPost - Block of markdown text

Important: If [text]: QuickReply mapping is used, the buttons are attached to the last TextPost instead of being sent as an individual message. This is mainly used to avoid using Title from Options in Watson Response and also prevents prefixing the option buttons with empty message box.

0.8.2

1 year ago

0.8.1

2 years ago

0.6.3

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.2

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.6.1

2 years ago

0.5.2

2 years ago

0.6.0

2 years ago

0.4.0

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.8

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.5

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.2.0

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago