UNPKG

@botonic/plugin-flow-builder

Version:

Botonic plugin for **Hubtype Flow Builder**: run and bridge flow-driven logic from bots on the **current** line.

37 lines 1.75 kB
import { __awaiter } from "tslib"; import { getTextOrTranscript, isKeywordsAllowed, isSmartIntentsAllowed, } from '../utils'; import { CaptureUserInputApi } from './capture-user-input'; import { KeywordMatcher } from './keyword'; import { SmartIntentsApi } from './smart-intent'; export function getNextPayloadByUserInput(cmsApi, locale, botonicContext, smartIntentsConfig) { return __awaiter(this, void 0, void 0, function* () { const userTextOrTranscript = getTextOrTranscript(botonicContext.input); if (userTextOrTranscript) { if (cmsApi.shouldCaptureUserInput()) { const captureUserInputApi = new CaptureUserInputApi(cmsApi, botonicContext, userTextOrTranscript); return yield captureUserInputApi.getNextNodeId(); } if (isKeywordsAllowed(botonicContext)) { const keywordMatcher = new KeywordMatcher({ cmsApi, locale, botonicContext, userTextOrTranscript, }); const keywordNode = yield keywordMatcher.getNodeByInput(); if (keywordNode) { return cmsApi.getPayload(keywordNode.target); } } if (isSmartIntentsAllowed(botonicContext)) { const smartIntentsApi = new SmartIntentsApi(cmsApi, botonicContext, smartIntentsConfig, userTextOrTranscript); const smartIntentNode = yield smartIntentsApi.getNodeByInput(); if (smartIntentNode) { return cmsApi.getPayload(smartIntentNode.target); } } } return undefined; }); } //# sourceMappingURL=index.js.map