Conversation context manager
npm install conv-contextjavascript
const Context = require('conv-context');
const context = new Context(contextData, thread);
`Resolve context from
contextData
`javascript
// resolver - optional resolver function
const resolvedContext = await context.resolve(resolver=defaultResolver);
`$3
`javascript
const resolver = async function (output, store) {
// your code here
// ...
};
`Get context data
`javascript
// 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
`javascript
// 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
`javascript
// save context data to session and shared (optional) storage
await context.save(shared=true, ttl=null)
`#### helper methods for each storage
`javascript
// save session data
context.setSession();// save shared session data
await context.setShared(ttl);
``