UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

26 lines 994 B
import { BaseContext } from "../../../../../helper/BaseContext"; /** * Stores the question answer into the Context and/or Input */ export const storeQuestionAnswer = ({ storeResultInContext, contextKey, context, result, input }) => { if (storeResultInContext && contextKey) { // check whether contextKey or inputKey is a deep query and set // storage location accordingly let location = context; let target = contextKey; // this is a deep query if (target.indexOf(".") > -1) { const splits = target.split("."); location = BaseContext.findLocationPathStateless(splits, true, location); target = splits[splits.length - 1]; } location[target] = result; // always store result also in input to allow for // easy handling in conditions etc. input.result = result; } else { input.result = result; } }; //# sourceMappingURL=storeQuestionAnswer.js.map