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

@acpaas-ui-widgets/nodejs-chatbot

v2.3.1

Published

Chatbot Smart Widget BFF package (Node)

Downloads

16

Readme

Build Status Coverage Status

Chatbot Smart Widget BFF (Node)

This is a Node.js backend service library to create a BFF service for the Chatbot Smart Widget. The widget provides a chat interface.

There is a demo service, see below for instructions on running it.

How to use

Installing

Copy the .npmrc file from this repo to your application's folder.

Then install (you will need to be on the digipolis network):

> npm install --save @acpaas-ui-widgets/nodejs-chatbot

Using

Express example:

const express = require('express');
const chatbotService = require('@acpaas-ui-widgets/nodejs-chatbot-service');

const app = express();

const controller = chatbotService.chatbot.createController({
  accessToken: <ACCESS_TOKEN> (you can find this in the chatbot interface under 'Instellingen'),
  chatbot: <CHATBOT> the Id of the chatbot you want to address,
  chatbotenv: <CHATBOT_ENV> test | production,
  serviceUrl: <SERVICEURL> endpoint (api-store),
  responseHandler: (optional) true(default) | false. The package needs to handle the http response or call 'next()'
  apikey: <APIKEY> the apikey from the api-store
});

app.post('/api/chatbot', controller);
app.listen(3000);

Typescript example:

import * as express from 'express';
import chatbotService from '@acpaas-ui-widgets/nodejs-chatbot';

const app = express();

const controller = chatbotService.createController({
  accessToken: <ACCESS_TOKEN> (you can find this in the chatbot interface under 'Instellingen'),
  chatbot: <CHATBOT> the Id of the chatbot you want to address,
  chatbotenv: <CHATBOT_ENV> test | production,
  serviceUrl: <SERVICEURL> endpoint (api-store),
  apikey: <APIKEY> the apikey from the api-store
});

app.post('/api/chatbot', controller);
app.listen(3000);

Run the demo app

Create a .env file containing:

ACCESS_TOKEN=
CHATBOT=
CHATBOT_ENV=
PORT=(optional, defaults to 3000)
SERVICEURL=
TOKEN=
APIKEY=

Obtain the APIKEY by taking out a contract on the chatbot-api service on api-store.antwerpen.be. The ACCESS_TOKEN value can be obtained at the bottom of the settings screen ("API token") on chatbots.antwerpen.be.

(Add -o or -a extensions where needed to the host names to access the development or acceptance environments.)

Run the service:

> npm install
> npm start

Service Specification

POST: /chats/{botId}/message?access_token={access_token}
{
  "message": "Hello World",
  "session_id": "<your session id>",
  "type": "message",
  "send": "true",
  "metadata": {
    "firstname": "Example",
    "lastname:": "name",
    "..." : "..."
  }
}
  • message: Your message to the bot,
  • session_id: The chatsession
  • type: message
  • send: true
  • metadata:: Metadata to be passed along, this has to be an object.

ResponseHandler

If the responseHandler is set to false the package will not send the http response. Instead it will call the next function and put the response on req.chatbotResponse. This feature can be used if you would like to modify / filter the message before it's sent to the client.

An example swagger description is included.

Contributing

We welcome your bug reports and pull requests.

Please see our contribution guide.

License

This project is published under the MIT license.