Skip to content
ChatShipper Node.js SDK
Branch: master
Clone or download
Latest commit 6bb5921 May 28, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Merge branch 'master' of github.com:chatshipper/chipchat May 28, 2019
examples Add bot triggers example May 28, 2019
lib Fix extras object May 28, 2019
.eslintignore Initial commit Apr 6, 2019
.eslintrc
.gitignore Exclude jsdoc from git May 11, 2019
.nvmrc Bump node version to 8.15.0 May 24, 2019
CHANGELOG.md Initial commit Apr 6, 2019
CONTRIBUTING.md Add contribution info Apr 28, 2019
LICENSE Initial commit Apr 6, 2019
README.md Update README May 26, 2019
package-lock.json version 0.1.1 May 28, 2019
package.json version 0.1.1 May 28, 2019

README.md

ChipChat is the ChatShipper Node.js SDK that helps you manage ChatShipper resources and build chat bots. This library provides convenient access to the ChatShipper API from applications written in server-side JavaScript.

Installation

Install the package with:

  $ npm install chipchat --save

Usage

The package needs to be configured with your account's API token which is available in your ChatShipper Dashboard.

'use strict';

const ChipChat = require('chipchat');

// Create a new bot instance
const bot = new ChipChat({
    token: process.env.TOKEN
});

// Use any REST resource
bot.users.get(bot.auth.user).then((botUser) => {
    console.log(`Hello ${botUser.name}`);
});

// Listen to some resource events
bot.on('user.login', (payload) => {
    console.log(payload.activity.summary);
});
bot.on('organization.create', (payload) => {
    console.log('Organization created', payload.activity.summary);
});

// Accept all bot notifications
bot.on('notify', (message, conversation) => conversation.accept());

// Echo all messages as text
bot.on('message', (message, conversation) => conversation.say(`Echo: ${message.text}`));

// Subscribe using wildcards, respond to consumer
bot.on('message.*.contact.*', (message, conversation) => {
    conversation.say({ text: '👍', role: 'agent' });
});

// Listen to utterances
bot.onText(['hi', /hello/], (_, conversation) => conversation.reply('Hey there'));

// Start Express.js webhook server to start listening
bot.start();

See Quickstart to get started.

Features

  • Full ChatShipper API v2 support
  • Start conversations, ask questions and save important information in the context of the conversation.
  • Organize your code in modules and middleware.
  • Subscribe to events.
  • http/https/express.js compatible webhooks
  • Easy to extend

API Resources

All organization resources available through the API can be accessed by the SDK: users, channels, contacts, conversations, messages, organizations, orggroups, services, forms, workflows, kbases, kbitems, articles and files.

Each resource has the methods list,get,create,update and delete available to it. See REST API for more information.

Receiving Events

You can subscribe to any webhook callback events received by the webhook with the bot.on() method. See our webhooks guide for a full list of possible events.

See Events for more information on event subsriptions; read Ingesting Events to see how to process payloads from webhooks and other sources.

Sending Messages

A conversation context encapsulates all properties of a ChatShipper conversation, augmented with message sending methods.

See Conversations for more information.

Extending ChipChat

Mixins

Mixins can be used to augment bot instances with your own functions.

Modules

Modules are simple functions that you can use to organize your code in different files and folders.

Middleware

Middlewares are functions that perform tasks before and after an operation (that call an API endpoint).

See Extending for more information.

Examples

For examples see the examples folder. To try any of the examples:

Configure environment:

export APIHOST=https://api.chatshipper.com
export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6I...

Then, try any of the examples:

cd examples
node example.js

Documentation

See the ChatShipper Developer Hub for full platform documentation.

You can’t perform that action at this time.