lexica-dialog-core
Version:
Core server for Lexica dialog agent.
26 lines • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = require("lodash");
const immutable_1 = require("immutable");
const conversationIntentMiddleware = async (context, next) => {
const { commands, sessionService } = context;
if (!lodash_1.isNil(sessionService) && sessionService.hasConversation()) {
const features = commands
.toArray()
.map(command => command.features)
.reduce((prev, next) => prev.merge(next), sessionService.getConversationFeatures());
const intent = sessionService.getConversationIntent();
context.commands = immutable_1.List([
{
attributes: immutable_1.Map(),
botResponses: immutable_1.List(),
features,
intent,
processedFeatures: immutable_1.Map(),
},
]);
}
await next();
};
exports.default = conversationIntentMiddleware;
//# sourceMappingURL=ConversationIntentMiddleware.js.map