Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add handoff options for shadowing, cancelHandoff and deleteUser #603

Merged
merged 7 commits into from
Mar 17, 2020
23 changes: 21 additions & 2 deletions packages/botonic-core/src/handoff.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ export class HandOffBuilder {
return this
}

withShadowing(shadowing = true) {
ericmarcos marked this conversation as resolved.
Show resolved Hide resolved
this._shadowing = shadowing
return this
}

async handOff() {
return _humanHandOff(
this._session,
this._queue,
this._onFinish,
this._email,
this._caseInfo,
this._note
this._note,
this._shadowing
)
}
}
Expand Down Expand Up @@ -87,7 +93,8 @@ async function _humanHandOff(
onFinish,
agentEmail = '',
caseInfo = '',
note = ''
note = '',
shadowing = false
) {
const params = {}
if (!queueNameOrId && agentEmail) {
Expand All @@ -105,6 +112,9 @@ async function _humanHandOff(
if (note) {
params.note = note
}
if (shadowing) {
params.shadowing = shadowing
}

if (onFinish) {
params.on_finish = onFinish
Expand Down Expand Up @@ -151,3 +161,12 @@ export async function getAvailableAgents(session) {
})
return resp.data
}

export function cancelHandoff(session, typification = null) {
ericmarcos marked this conversation as resolved.
Show resolved Hide resolved
let params = { typification }
ericmarcos marked this conversation as resolved.
Show resolved Hide resolved
session._botonic_action = `discard_case:${JSON.stringify(params)}`
ericmarcos marked this conversation as resolved.
Show resolved Hide resolved
}

export function deleteUser(session) {
ericmarcos marked this conversation as resolved.
Show resolved Hide resolved
session._botonic_action = `delete_user`
}
2 changes: 2 additions & 0 deletions packages/botonic-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export {
HandOffBuilder,
storeCaseRating,
getAvailableAgents,
cancelHandoff,
deleteUser,
} from './handoff'
export { getNLU } from './nlu'
export { isBrowser, isNode, isMobile, params2queryString } from './utils'
Expand Down