-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Updating for voxa3 * Adding generic * Moving to typescript * Updating tests * Updated dependencies * Changing cobertura for report and installing nyc. * Adding tslint-no-unused-expression-chai package for tslint to work. * Setting 3.0.0-alpha38 as minimum * Moving to yarn * Changing package version. * Updated dependencies * Support for facebook property * Added printErrors to config interface * Changed to v2.0.0-alpha4 * Removed facebook property * Changes to v2.0.0 * Updates dependencies * Updates run-ci.sh * Replaces nyc with istanbul * Changes to v2.0.1 * Removes ignored lib folder * Changes to v2.0.2
- Loading branch information
Showing
16 changed files
with
2,353 additions
and
1,488 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
v6.10 | ||
v8.10 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
/* | ||
* Copyright (c) 2018 Rain Agency <contact@rain.agency> | ||
* Author: Rain Agency <contact@rain.agency> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
* this software and associated documentation files (the "Software"), to deal in | ||
* the Software without restriction, including without limitation the rights to | ||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
* the Software, and to permit persons to whom the Software is furnished to do so, | ||
* subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
import * as _ from "lodash"; | ||
import { IVoxaEvent, IVoxaReply, VoxaApp } from "voxa"; | ||
/* tslint:disable-next-line */ | ||
const DashbotAnalytics = require("dashbot"); | ||
|
||
const defaultConfig = { | ||
ignoreUsers: [], | ||
}; | ||
|
||
const dashbotIntegrations: any = { | ||
alexa: "alexa", | ||
botframework: "generic", | ||
dialogflow: "google", // DEPRECATED | ||
google: "google", | ||
}; | ||
|
||
export interface IVoxaDashbotConfig { | ||
alexa?: string; | ||
api_key?: string; | ||
botframework?: string; | ||
debug?: boolean; | ||
dialogflow?: string; | ||
printErrors?: boolean; | ||
redact?: boolean; | ||
suppressSending?: boolean; | ||
timeout?: number; | ||
} | ||
|
||
export function register(skill: VoxaApp, config: IVoxaDashbotConfig) { | ||
const pluginConfig = _.merge({}, defaultConfig, config); | ||
|
||
const dashbotConfig = { | ||
debug: pluginConfig.debug, | ||
printErrors: pluginConfig.printErrors, | ||
redact: pluginConfig.redact, | ||
timeout: pluginConfig.timeout, | ||
}; | ||
|
||
skill.onRequestStarted(trackIncoming); | ||
skill.onBeforeReplySent(trackOutgoing); | ||
|
||
function trackIncoming(voxaEvent: IVoxaEvent) { | ||
if (_.includes(pluginConfig.ignoreUsers, voxaEvent.user.userId)) { | ||
return Promise.resolve(null); | ||
} | ||
if (pluginConfig.suppressSending) { | ||
return Promise.resolve(null); | ||
} | ||
const { rawEvent, platform } = voxaEvent; | ||
const apiKey = _.get(pluginConfig, platform.name) || pluginConfig.api_key; | ||
|
||
const Dashbot = DashbotAnalytics(apiKey, dashbotConfig)[ | ||
dashbotIntegrations[platform.name] | ||
]; | ||
// PROCESSING INCOMING RESPONSE | ||
return Dashbot.logIncoming(rawEvent); | ||
} | ||
|
||
function trackOutgoing(voxaEvent: IVoxaEvent, reply: IVoxaReply) { | ||
if (_.includes(pluginConfig.ignoreUsers, voxaEvent.user.userId)) { | ||
return Promise.resolve(null); | ||
} | ||
if (pluginConfig.suppressSending) { | ||
return Promise.resolve(null); | ||
} | ||
const { rawEvent, platform } = voxaEvent; | ||
const apiKey = _.get(pluginConfig, platform.name) || pluginConfig.api_key; | ||
|
||
const Dashbot = DashbotAnalytics(apiKey, dashbotConfig)[ | ||
dashbotIntegrations[platform.name] | ||
]; | ||
// PROCESSING INCOMING RESPONSE | ||
return Dashbot.logOutgoing(rawEvent, reply); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--require ts-node/register | ||
--watch-extensions ts | ||
--recursive | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"use strict"; | ||
|
||
/** | ||
* Views for tests | ||
* | ||
* Copyright (c) 2016 Rain Agency. | ||
* Licensed under the MIT license. | ||
*/ | ||
|
||
const views = (function views() { | ||
return { | ||
en: { | ||
translation: { | ||
LaunchIntent: { | ||
OpenResponse: "Hello! How are you?" | ||
}, | ||
Question: { | ||
Ask: "What time is it?" | ||
}, | ||
ExitIntent: { | ||
GeneralExit: "Ok. Goodbye." | ||
}, | ||
BadInput: { | ||
RepeatLastAskReprompt: "I'm sorry. I didn't understand." | ||
} | ||
} | ||
} | ||
}; | ||
})(); | ||
|
||
module.exports = views; |
Oops, something went wrong.