UNPKG

asksuite-core

Version:
30 lines (25 loc) 736 B
class KeyMatcherAccessor { constructor(awsLambdaCaller) { this.awsLambdaCaller = awsLambdaCaller; } resolveText(request) { let intent = null; return new Promise(resolve => { const executor = async () => { try { // KeyMatcher intent = await this.awsLambdaCaller.call(request, 'asksuite-NLP-dev-keyMatcherNLP'); if (!intent || !intent.intent) { throw new Error('Intent not present in response: \n' + JSON.stringify(intent)); } } catch (e) { intent = request.findIntent; console.log('Erro no keymatcher ', e); } resolve(intent); }; executor(); }); } } module.exports = KeyMatcherAccessor;