npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wa-chat-server-unblu

v0.8.2

Published

wa-chat-server adapter for Unblu

Downloads

12

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
  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.