🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

conv-context-next

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

conv-context-next

Conversation context manager

1.0.0
latest
npm
Version published
Maintainers
1
Created
Source

Conversation Context

A simple class that helps to handle bot conversation context.

Getting started

const Context = require('conv-context');
const context = new Context(contextData, thread);

Resolve context from contextData

// resolver - optional resolver function
const resolvedContext = await context.resolve(resolver=defaultResolver);

Custom resolver (binded to the step's 'this')

const resolver = async function (output, store) {
  // your code here
  // ...
};

Get context data

// get context for the 'name' entity. The path is also accepted: 'path.to.data'
context.get('name', data, defaultValue);

// get context from step with Id === stepId 
context.getStepContext(stepId)

// find step context by some filter criteria
context.findStepContext(query={})

// find step Id by some filter criteria
context.findStepId(query={})

// get step contexts by some filter criteria
context.filterStepContext(query={})

Set context data

// set context for the 'name' entity. The path is also accepted: 'path.to.data'
context.set('name', data);

// set step context
context.setStepContext(data)

Save context in the session and shared storage

// save context data to session and shared (optional) storage
await context.save(shared=true, ttl=null)

helper methods for each storage

// save session data
context.setSession();

// save shared session data
await context.setShared(ttl);

Keywords

bot

FAQs

Package last updated on 24 Mar 2023

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