new(all): Automation new keywords and WhatsApp transfer.
This commit is contained in:
parent
cea3b54970
commit
156eebc251
4 changed files with 15 additions and 14 deletions
|
@ -578,7 +578,7 @@ export class DialogKeywords {
|
||||||
* @example TRANSFER
|
* @example TRANSFER
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async transfer(step, to: string = null) {
|
public async transferTo(step, to: string = null) {
|
||||||
return await step.beginDialog('/t', {to: to});
|
return await step.beginDialog('/t', {to: to});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -374,11 +374,11 @@ export class GBVMService extends GBService {
|
||||||
});
|
});
|
||||||
|
|
||||||
code = code.replace(/(transfer to)(\s)(.*)/gi, ($0, $1, $2, $3) => {
|
code = code.replace(/(transfer to)(\s)(.*)/gi, ($0, $1, $2, $3) => {
|
||||||
return `transfer (step, ${$3})\n`;
|
return `transferTo (step, ${$3})\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
code = code.replace(/(transfer)(?=(?:[^"]|"[^"]*")*$)/gi, () => {
|
code = code.replace(/(\btransfer\b)(?=(?:[^"]|"[^"]*")*$)/gi, () => {
|
||||||
return `transfer (step)\n`;
|
return `transferTo (step)\n`;
|
||||||
});
|
});
|
||||||
|
|
||||||
code = code.replace(/(exit)/gi, () => {
|
code = code.replace(/(exit)/gi, () => {
|
||||||
|
@ -599,8 +599,8 @@ export class GBVMService extends GBService {
|
||||||
code = code.replace(/("[^"]*"|'[^']*')|\bsetWholeWord\b/gi, ($0, $1) => {
|
code = code.replace(/("[^"]*"|'[^']*')|\bsetWholeWord\b/gi, ($0, $1) => {
|
||||||
return $1 === undefined ? 'this.setWholeWord' : $1;
|
return $1 === undefined ? 'this.setWholeWord' : $1;
|
||||||
});
|
});
|
||||||
code = code.replace(/("[^"]*"|'[^']*')|\btransfer\b/gi, ($0, $1) => {
|
code = code.replace(/("[^"]*"|'[^']*')|\btransferTo\b/gi, ($0, $1) => {
|
||||||
return $1 === undefined ? 'this.transfer' : $1;
|
return $1 === undefined ? 'this.transferTo' : $1;
|
||||||
});
|
});
|
||||||
code = code.replace(/("[^"]*"|'[^']*')|\bcreateDeal\b/gi, ($0, $1) => {
|
code = code.replace(/("[^"]*"|'[^']*')|\bcreateDeal\b/gi, ($0, $1) => {
|
||||||
return $1 === undefined ? 'this.createDeal' : $1;
|
return $1 === undefined ? 'this.createDeal' : $1;
|
||||||
|
|
|
@ -84,18 +84,19 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
const sec = new SecService();
|
const sec = new SecService();
|
||||||
let from = GBMinService.userMobile(step);
|
let from = GBMinService.userMobile(step);
|
||||||
const user = await min.userProfile.get(step.context, {});
|
const profile = await min.userProfile.get(step.context, {});
|
||||||
|
const args = step.activeDialog.state.options;
|
||||||
const args = step.activeDialog.state.options.args;
|
|
||||||
|
|
||||||
// Transfer to...
|
// Transfer to...
|
||||||
|
|
||||||
if (args && args.to) {
|
if (args && args.to) {
|
||||||
|
|
||||||
|
|
||||||
// An user from Teams willing to transfer to a WhatsApp user.
|
// An user from Teams willing to transfer to a WhatsApp user.
|
||||||
|
|
||||||
await sec.assignHumanAgent(min, args.to, user.userSystemId);
|
await sec.ensureUser(min.instance.instanceId, args.to,
|
||||||
|
'Name', '', 'whatsapp', 'Name', null);
|
||||||
|
|
||||||
|
await sec.assignHumanAgent(min, args.to, profile.systemUser.userSystemId);
|
||||||
await min.conversationalService.sendText(min, step,
|
await min.conversationalService.sendText(min, step,
|
||||||
Messages[locale].notify_agent_transfer_done(min.instance.botId));
|
Messages[locale].notify_agent_transfer_done(min.instance.botId));
|
||||||
|
|
||||||
|
@ -105,8 +106,8 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
|
|
||||||
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
||||||
const agentSystemId = await sec.assignHumanAgent(min, from);
|
const agentSystemId = await sec.assignHumanAgent(min, from);
|
||||||
user.systemUser = await sec.getUserFromAgentSystemId(agentSystemId);
|
profile.systemUser = await sec.getUserFromAgentSystemId(agentSystemId);
|
||||||
await min.userProfile.set(step.context, user);
|
await min.userProfile.set(step.context, profile);
|
||||||
|
|
||||||
if (agentSystemId.charAt(2) === ":" || agentSystemId.indexOf("@") > -1) { // Agent is from Teams or Google Chat.
|
if (agentSystemId.charAt(2) === ":" || agentSystemId.indexOf("@") > -1) { // Agent is from Teams or Google Chat.
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ export class SecService extends GBService {
|
||||||
instanceId: number,
|
instanceId: number,
|
||||||
agentSystemId: string
|
agentSystemId: string
|
||||||
): Promise<GuaribasUser> {
|
): Promise<GuaribasUser> {
|
||||||
const user = await GuaribasUser.findOne({
|
const user = await GuaribasUser.findOne({
|
||||||
where: {
|
where: {
|
||||||
userSystemId: userSystemId,
|
userSystemId: userSystemId,
|
||||||
instanceId: instanceId
|
instanceId: instanceId
|
||||||
|
|
Loading…
Add table
Reference in a new issue