# wa-chat-server-unblu

> wa-chat-server adapter for Unblu

Latest version **0.8.2** (published 2023-02-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install wa-chat-server-unblu
pnpm add wa-chat-server-unblu
yarn add wa-chat-server-unblu
bun add wa-chat-server-unblu
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.2 |
| Published | 2023-02-22 |
| First published | 2022-03-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 170.6 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | IBM AI CoE Prague |
| Maintainers | boris.podskalicky |
| Keywords | Watson, Chat, Server, Unblu |

## Links

- npm: https://www.npmjs.com/package/wa-chat-server-unblu
- Repository: git@github.ibm.com:AI-CoE-Prague/wa-chat-server-unblu
- npm.io page: https://npm.io/package/wa-chat-server-unblu

## Dependencies (4)

- [xss](https://npm.io/package/xss.md) ^1.0.11
- [axios](https://npm.io/package/axios.md) ^0.26.1
- [typescript](https://npm.io/package/typescript.md) ^4.6.2
- [wa-chat-server](https://npm.io/package/wa-chat-server.md) ^0.15.6

## Recent versions

- 0.8.2 (latest) — 2023-02-22
- 0.8.1 — 2022-10-10
- 0.7.1 — 2022-09-30
- 0.7.0 — 2022-09-29
- 0.6.3 — 2022-09-07
- 0.6.2 — 2022-06-15
- 0.6.1 — 2022-06-15
- 0.6.0 — 2022-05-30
- 0.5.3 — 2022-05-26
- 0.5.2 — 2022-05-25
- 0.5.0 — 2022-05-19
- 0.4.0 — 2022-05-11
- 0.3.4 — 2022-04-29
- 0.3.3 — 2022-04-28
- 0.3.2 — 2022-04-22
- … 14 more at https://npm.io/package/wa-chat-server-unblu/versions

## README

# 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`):

| Variable                              | Obligatory | Meaning                                                                                                                                                                                                                                   |
| ------------------------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `adapter__unblu__unbluApiUrl`         | Y          | Base URL for API endpoints on Unblu Collaboration Server, up to API version (../rest/v3)                                                                                                                                                  |
| `adapter__unblu__unbluApiUsername`    | Y          | Unblu basic authentication Username (account is created in Unblu Web UI)                                                                                                                                                                  |
| `adapter__unblu__unbluApiPassword`    | Y          | Unblu basic authentication Password (account is created in Unblu Web UI)                                                                                                                                                                  |
| `adapter__unblu__webhookApiKey`       | N          | Secret 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__webhookSecuritySha1` | N          | If 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__messageStaggerMs`    | N          | Amount in milliseconds between messages when sending multiple responses to a single request (default is 600)                                                                                                                              |
| `adapter__unblu__fallbackMessages`    | N          | Messages 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__mapping`             | N          | Use 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
1. `option` - Options
1. `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
1. `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
1. `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.

---
_Source: https://npm.io/package/wa-chat-server-unblu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
