New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@djragsdale/intent-manager

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@djragsdale/intent-manager

Create and manage conversational interactions

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

@djragsdale/intent-manager

Usage

The intent manager package should be able to be used as either a CommonJS module or EcmaScript module.

import { IntentManager } from '@djragsdale/intent-manager';
const { IntentManager } = require('@djragsdale/intent-manager');

Adding Utterances From File

import { IntentManager } from '@djragsdale/intent-manager';
import path from 'path';

(async () => {
  const intentManager = new IntentManager();

  await intentManager.loadUtterancesFromFile(path.join(__dirname, '../__fixtures__/sampleUtterances.txt'));
})();

Adding Utterances From Strings

import { IntentManager } from '@djragsdale/intent-manager';

const intentManager = new IntentManager();

intentManager.loadUtteranceFromString('GetInfo get {object} info');

export default intentManager;

Using Intent Handlers

import { IntentManager } from '@djragsdale/intent-manager';

const intentManager = new IntentManager();

intentManager.loadUtteranceFromString('GetInfo get {object} info');
intentManager.addIntentHandler({
  intentName: 'GetInfo',
  handler: async (intent) => {
    await doAsyncThings(intent);
  },
});

intentManager.execute('get user info');

Handling Intent Matches Manually

import { IntentManager } from '@djragsdale/intent-manager';

const intentManager = new IntentManager();

intentManager.loadUtteranceFromString('GetInfo get {object} info');

intentManager.on('intent:found', (intent) => {
  console.log(`Handling ${intent.name} the event way`);
});
intentManager.on('intent:notFound', ({ phrase }) => {
  console.log(`Could not match the phrase "${phrase}"`);
});

const intent = intentManager.matchIntent('get user info');

if (!intent) {
  console.error('Intent not found');
}
doSyncThings(intent);

Streaming Into the Intent Manager

import { IntentManager } from '@djragsdale/intent-manager';

const intentManager = new IntentManager();

intentManager.loadUtteranceFromString('GetInfo get {object} info');
intentManager.addIntentHandler({
  intentName: 'GetInfo',
  handler: (intent) => {
    console.log('Found intent', intent.name, intent.slots.object);
  },
});

process.stdin.pipe(intentManager);

Streaming Out of the Intent Manager

import { IntentManager } from '@djragsdale/intent-manager';

const intentManager = new IntentManager();

intentManager.loadUtteranceFromString('GetInfo get {object} info');
intentManager.addIntentHandler({
  intentName: 'GetInfo',
  handler: intent => `Found intent ${intent.name} ${intent.slots.object}\n`,
});

process.stdin.pipe(intentManager).pipe(process.stdout);

Keywords

FAQs

Package last updated on 27 Oct 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc