Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ChipChat is the Web1on1 Node.js SDK that helps you manage Web1on1 resources and build chat bots. This library provides convenient access to the Web1on1 API from applications written in server-side JavaScript.
Install the package with:
$ npm install chipchat --save
The package needs to be configured with your account's API token which is available in your Web1on1 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.
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.
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.
A conversation context encapsulates all properties of a Web1on1 conversation, augmented with message sending methods.
See Conversations for more information.
Sometimes you want to add some special header to each request. Here is how to do this.
const token = 'xxx';
new ChipChat({
token,
fetchExtensions: {
beforeRequest: [async (options) => {
options.headers = {
...options.headers,
'extraheader': 'some value'
}
}]
}
}
Mixins can be used to augment bot instances with your own functions.
Modules are simple functions that you can use to organize your code in different files and folders.
Middlewares are functions that perform tasks before and after an operation (that call an API endpoint).
See Extending for more information.
See Internal API spec for a full list of possible constructor options. Some options can also be specified as environment variables. These are:
option | environment variable | default value |
---|---|---|
port | 3000 | |
secret | secret | null |
webhook | webhook_path | / |
host | apihost | https://api.web1on1.chat |
To run the test suite you have to create a .env file in your local Project dir and add the following keys:
key | explanation |
---|---|
CS_ORGANIZATION=5ee7317e... | Create your own sdk test org in CS and add the org id here |
CS_ADMIN=5ee7372448... | Id of a bot on sandbox organization |
CS_ADMIN_EMAIL=bot+5ee7372448...@web1on1.chat | email of the bot on sandbox organization and add its id here |
CS_TOKEN=eyJhbGciOiJIUzI1Ni... | generate a token by logging in as the admin user and generate tokens in account > developer > tokens |
CS_REFRESHTOKEN=eyJhbGciOiJ... | generate a refresh token and add here |
then run:
npm run test
Running thhe examples requires the TOKEN
environment variable set as a valid API access token.
For examples see the examples folder. To try any of the examples, first set the TOKEN
environment variable as a valid API access token:
export TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6I...
Then, try any of the examples:
cd examples
node example.js
See the Web1on1 Developer Hub for full platform documentation.
FAQs
Web1on1 JavaScript SDK
We found that chipchat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.