diff --git a/packages/botonic-core/src/core-bot.js b/packages/botonic-core/src/core-bot.js index c8a4d7cbdd..13e3b5c6d2 100644 --- a/packages/botonic-core/src/core-bot.js +++ b/packages/botonic-core/src/core-bot.js @@ -1,6 +1,5 @@ import { Inspector } from './debug/inspector' import { getString } from './i18n' -import { getNLU } from './nlu' import { loadPlugins, runPlugins } from './plugins' import { Router } from './router' import { isFunction } from './utils' @@ -10,7 +9,6 @@ export class CoreBot { renderer, routes, locales, - integrations, theme, plugins, appId, @@ -26,7 +24,6 @@ export class CoreBot { typeof defaultTyping !== 'undefined' ? defaultTyping : 0.6 this.defaultDelay = typeof defaultDelay !== 'undefined' ? defaultDelay : 0.4 this.locales = locales - this.integrations = integrations if (appId) { this.appId = appId return @@ -57,11 +54,6 @@ export class CoreBot { if (this.plugins) { await runPlugins(this.plugins, 'pre', input, session, lastRoutePath) - } else if (this.integrations && input.type == 'text') { - try { - const nlu = await getNLU(input, this.integrations) - Object.assign(input, nlu) - } catch (e) {} } if (isFunction(this.routes)) { diff --git a/packages/botonic-core/src/index.d.ts b/packages/botonic-core/src/index.d.ts index 1213b8a7ca..a3c50ff744 100644 --- a/packages/botonic-core/src/index.d.ts +++ b/packages/botonic-core/src/index.d.ts @@ -280,7 +280,6 @@ export interface BotOptions { defaultRoutes?: Route[] defaultTyping?: number inspector?: Inspector - integrations?: { [id: string]: any } locales: Locales routes: Routes theme?: string @@ -291,7 +290,6 @@ export interface BotOptions { export class CoreBot { defaultDelay: number defaultTyping: number - integrations?: { [id: string]: any } locales: Locales plugins: { [id: string]: Plugin } routes: Routes diff --git a/packages/botonic-core/src/index.js b/packages/botonic-core/src/index.js index 26ffab8b09..60a0c13336 100644 --- a/packages/botonic-core/src/index.js +++ b/packages/botonic-core/src/index.js @@ -14,7 +14,6 @@ export { } from './handoff' export { HubtypeService } from './hubtype-service' export { getString } from './i18n' -export { getNLU } from './nlu' export { Router } from './router' export { isBrowser, isMobile, isNode, params2queryString } from './utils' diff --git a/packages/botonic-core/src/nlu.js b/packages/botonic-core/src/nlu.js deleted file mode 100644 index 069133f20a..0000000000 --- a/packages/botonic-core/src/nlu.js +++ /dev/null @@ -1,69 +0,0 @@ -import axios from 'axios' -//import { AssistantV1 } from 'watson-developer-cloud/assistant/v1' - -export async function getNLU(input, integrations) { - const df_session_id = Math.random() - let intent = null - let confidence = 0 - let intents = [] - let entities = [] - if (!integrations) return { intent, confidence, intents, entities } - if (integrations.dialogflow) { - try { - const dialogflow_resp = await axios({ - headers: { - Authorization: 'Bearer ' + integrations.dialogflow.token, - }, - url: 'https://api.dialogflow.com/v1/query', - params: { - query: input.data, - lang: 'en', - sessionId: df_session_id, - }, - }) - if (dialogflow_resp && dialogflow_resp.data) { - intent = dialogflow_resp.data.result.metadata.intentName - entities = dialogflow_resp.data.result.parameters - } - } catch (e) {} - } else if (integrations.watson) { - // AssistantV1 only works for Node - /*let w = integrations.watson - let assistant = new AssistantV1({ - version: '2017-05-26', - ...integrations.watson - }) - - assistant.message = util.promisify(assistant.message) - - try { - let res = await assistant.message({ - input: { text: input.data }, - workspace_id: integrations.watson.workspace_id - }) - intent = res.intents[0].intent - confidence = res.intents[0].confidence - intents = res.intents - entities = res.entities - } catch (e) {}*/ - } else if (integrations.luis) { - const luis = integrations.luis - try { - const luis_resp = await axios({ - url: `https://${luis.region}.api.cognitive.microsoft.com/luis/v2.0/apps/${luis.appID}`, - params: { - 'subscription-key': luis.endpointKey, - q: input.data, - verbose: true, - }, - }) - if (luis_resp && luis_resp.data) { - intent = luis_resp.data.topScoringIntent.intent - confidence = luis_resp.data.topScoringIntent.score - intents = luis_resp.data.intents - entities = luis_resp.data.entities - } - } catch (e) {} - } - return { intent, confidence, intents, entities } -}