
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
A Nodejs framework to write stories in JS for a Tock chatbot.
🏠 Home: https://doc.tock.ai
💬 Contact: https://gitter.im/tockchat/Lobby
yarn add tock-node
npm i tock-node
The package has TypeScript type definitions
const { Bot } = require('tock-node');
const bot = new Bot('<TOCK_API_KEY>', '<TOCK_HOST>', <TOCK_WS_PORT>, '<TOCK_WS_PROTOCOL>');
bot.addStory('intent', bot => {
bot.send('Hello World!');
});
Default Tock platform host, port and WebSocket protocol are demo-bot.tock.ai (the public demo),
443 and wss (secured port/protocol).
For more examples, see tock-node-example.
You can call send as many times as you need. All messages will be sent within the same response.
bot.addStory('intent', bot => {
bot.send('Good morning!');
bot.send('How are you?');
});
You can use send to send other message templates such as cards.
const imageCard = require('tock-node').imageCard;
const action = require('tock-node').action;
bot.send(imageCard('Card title', 'Card description', 'https://site/image.png', action('Button')));
There is also a template that lets you send multiple cards in a carousel.
const imageCard = require('tock-node').imageCard;
const action = require('tock-node').action;
bot.send({
cards: [
imageCard('Card 1', '', 'https://site/image.png'),
imageCard('Card 2', '', 'https://site/image.png'),
imageCard('Card 3', '', 'https://site/image.png'),
],
});
Quick replies are highly buttons that are following a message. You can send quick replies following a message using send.
const suggestion = require('tock-node').suggestion;
bot.send('Check this out!', suggestion('View Tock on GitHub'), suggestion("View Tock's Website"));
You can get the original user request (containing his message) from the second argument of the story handler. This is also how you retrieve entities found by Tock.
bot.addStory('intent', (bot, request) => {
// user message
console.log(request.message.text);
// entities
console.log(request.entities);
});
Each user has a user context that is persistent across all stories. You can use it and also set it.
bot.addStory('intent', bot => {
// getting user context
console.log(bot.userData);
// setting
bot.dispatchUserData({ firstName: 'Tockito' });
});
In the case of multiple dispatches you can retrieve the current user data by using a callback function that uses the current user data as an argument.
bot.addStory('intent', bot => {
bot.dispatchUserData({ firstName: 'Foo' });
bot.dispatchUserData(userData => {
console.log(userData);
// {"firstname":"Foo"}
return { firstName: userData.firstName, lastName: 'Bar' };
});
});
If you'd like to wait for an action before sending you can use a Promise as a callback to your story handler.
bot.addStory('intent', async bot => {
const message = await fetchingData();
bot.send(message);
});
You can add as many story handlers as you want in the same addStory.
const handler1 = bot => send('First handler');
const handler2 = bot => send('Second handler');
bot.addStory('intentA', handler1, handler2);
bot.addStory('intentB', handler1, handler2);
FAQs
Nodejs framework to create stories for Tock chatbots
The npm package tock-node receives a total of 13 weekly downloads. As such, tock-node popularity was classified as not popular.
We found that tock-node demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.