webitel-sdk 0.1.185 → 0.1.186
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/index.esm.js +69 -10
- package/bundles/index.esm.js.map +1 -1
- package/bundles/index.esm.min.js +1 -1
- package/bundles/index.esm.min.js.map +1 -1
- package/bundles/index.umd.js +114 -11
- package/bundles/index.umd.js.map +1 -1
- package/bundles/index.umd.min.js +1 -1
- package/bundles/index.umd.min.js.map +1 -1
- package/esm2015/socket/agent.js +0 -6
- package/esm2015/socket/agent.js.map +1 -1
- package/esm2015/socket/client.js.map +1 -1
- package/esm2015/socket/conversation.js +33 -4
- package/esm2015/socket/conversation.js.map +1 -1
- package/esm2015/socket/task.js +37 -0
- package/esm2015/socket/task.js.map +1 -1
- package/esm5/socket/agent.js +0 -7
- package/esm5/socket/agent.js.map +1 -1
- package/esm5/socket/client.js.map +1 -1
- package/esm5/socket/conversation.js +55 -4
- package/esm5/socket/conversation.js.map +1 -1
- package/esm5/socket/task.js +60 -0
- package/esm5/socket/task.js.map +1 -1
- package/package.json +1 -1
- package/types/socket/agent.d.ts.map +1 -1
- package/types/socket/client.d.ts.map +1 -1
- package/types/socket/conversation.d.ts +6 -1
- package/types/socket/conversation.d.ts.map +1 -1
- package/types/socket/task.d.ts +6 -0
- package/types/socket/task.d.ts.map +1 -1
package/bundles/index.esm.js
CHANGED
|
@@ -32882,6 +32882,9 @@ class Task {
|
|
|
32882
32882
|
this.stopAt = 0;
|
|
32883
32883
|
this.closedAt = 0;
|
|
32884
32884
|
this.form = null;
|
|
32885
|
+
this.autoAnswered = false;
|
|
32886
|
+
this._autoAnswerParam = false;
|
|
32887
|
+
this._autoAnswerTimerId = null;
|
|
32885
32888
|
this.communication = distribute.communication;
|
|
32886
32889
|
this.history = [distribute];
|
|
32887
32890
|
}
|
|
@@ -32934,9 +32937,19 @@ class Task {
|
|
|
32934
32937
|
setAnswered(t) {
|
|
32935
32938
|
this.answeredAt = t;
|
|
32936
32939
|
this.lastStatusChange = Date.now();
|
|
32940
|
+
if (this._autoAnswerTimerId) {
|
|
32941
|
+
clearTimeout(this._autoAnswerTimerId);
|
|
32942
|
+
this._autoAnswerTimerId = null;
|
|
32943
|
+
}
|
|
32937
32944
|
}
|
|
32938
32945
|
setOffering(e) {
|
|
32939
32946
|
this.offeringAt = e.timestamp;
|
|
32947
|
+
if (e.offering.auto_answer && this.channel === ChannelType.Job) {
|
|
32948
|
+
this._autoAnswerParam = e.offering.auto_answer;
|
|
32949
|
+
this.acceptDelay().catch((err) => {
|
|
32950
|
+
this.client.emit('error', err);
|
|
32951
|
+
});
|
|
32952
|
+
}
|
|
32940
32953
|
}
|
|
32941
32954
|
setBridged(e) {
|
|
32942
32955
|
this.bridgedAt = e.timestamp;
|
|
@@ -33010,6 +33023,18 @@ class Task {
|
|
|
33010
33023
|
}
|
|
33011
33024
|
return this._processing.renewal_sec;
|
|
33012
33025
|
}
|
|
33026
|
+
get autoAnswer() {
|
|
33027
|
+
return this.autoAnswerDelay > 0;
|
|
33028
|
+
}
|
|
33029
|
+
get autoAnswerDelay() {
|
|
33030
|
+
if (!this._autoAnswerParam || `${this._autoAnswerParam}` === 'false') {
|
|
33031
|
+
return 0;
|
|
33032
|
+
}
|
|
33033
|
+
else if (isFinite(+this._autoAnswerParam)) {
|
|
33034
|
+
return +this._autoAnswerParam;
|
|
33035
|
+
}
|
|
33036
|
+
return this.client.autoAnswerDelayTime;
|
|
33037
|
+
}
|
|
33013
33038
|
/*
|
|
33014
33039
|
control
|
|
33015
33040
|
*/
|
|
@@ -33020,6 +33045,17 @@ class Task {
|
|
|
33020
33045
|
app_id: this.distribute.app_id,
|
|
33021
33046
|
});
|
|
33022
33047
|
}
|
|
33048
|
+
async acceptDelay() {
|
|
33049
|
+
if (this.autoAnswered) {
|
|
33050
|
+
return;
|
|
33051
|
+
}
|
|
33052
|
+
this.autoAnswered = true;
|
|
33053
|
+
this._autoAnswerTimerId = setTimeout(async () => {
|
|
33054
|
+
if (!this.answeredAt) {
|
|
33055
|
+
await this.accept();
|
|
33056
|
+
}
|
|
33057
|
+
}, this.autoAnswerDelay);
|
|
33058
|
+
}
|
|
33023
33059
|
async close() {
|
|
33024
33060
|
return this.client.request(`cc_agent_task_close`, {
|
|
33025
33061
|
agent_id: this.distribute.agent_id,
|
|
@@ -33179,12 +33215,6 @@ class Agent {
|
|
|
33179
33215
|
task = this.task.get(e.attempt_id);
|
|
33180
33216
|
if (task) {
|
|
33181
33217
|
task.setOffering(evOffering);
|
|
33182
|
-
if (evOffering.offering.auto_answer &&
|
|
33183
|
-
task.channel === ChannelType.Job) {
|
|
33184
|
-
task.accept().catch((err) => {
|
|
33185
|
-
this.client.emit('error', err);
|
|
33186
|
-
});
|
|
33187
|
-
}
|
|
33188
33218
|
}
|
|
33189
33219
|
break;
|
|
33190
33220
|
case ChannelState.Bridged:
|
|
@@ -33888,13 +33918,15 @@ class Conversation {
|
|
|
33888
33918
|
this.state = ConversationState.Invite;
|
|
33889
33919
|
this.variables = {};
|
|
33890
33920
|
this._hasReporting = !!(variables && variables.cc_reporting === 'true');
|
|
33891
|
-
this.
|
|
33921
|
+
this.autoAnswered = false;
|
|
33922
|
+
this._autoAnswerParam = false;
|
|
33923
|
+
this._autoAnswerTimerId = null;
|
|
33892
33924
|
this._cause = null;
|
|
33893
33925
|
this.lastAction = null;
|
|
33894
33926
|
for (const k in variables) {
|
|
33895
33927
|
if (!k.startsWith('cc_') && variables.hasOwnProperty(k)) {
|
|
33896
33928
|
if (k === 'wbt_auto_answer') {
|
|
33897
|
-
this.
|
|
33929
|
+
this._autoAnswerParam = variables.wbt_auto_answer;
|
|
33898
33930
|
}
|
|
33899
33931
|
else {
|
|
33900
33932
|
this.variables[k] = variables[k];
|
|
@@ -33914,16 +33946,32 @@ class Conversation {
|
|
|
33914
33946
|
setInvite(inviteId, timestamp) {
|
|
33915
33947
|
this.inviteId = inviteId;
|
|
33916
33948
|
this.invitedAt = timestamp;
|
|
33917
|
-
if (this.
|
|
33918
|
-
this.
|
|
33949
|
+
if (this.autoAnswer) {
|
|
33950
|
+
this.joinDelay().catch((e) => {
|
|
33919
33951
|
this.client.emit('error', e);
|
|
33920
33952
|
});
|
|
33921
33953
|
}
|
|
33922
33954
|
}
|
|
33955
|
+
get autoAnswer() {
|
|
33956
|
+
return this.autoAnswerDelay > 0;
|
|
33957
|
+
}
|
|
33958
|
+
get autoAnswerDelay() {
|
|
33959
|
+
if (!this._autoAnswerParam || `${this._autoAnswerParam}` === 'false') {
|
|
33960
|
+
return 0;
|
|
33961
|
+
}
|
|
33962
|
+
else if (isFinite(+this._autoAnswerParam)) {
|
|
33963
|
+
return +this._autoAnswerParam;
|
|
33964
|
+
}
|
|
33965
|
+
return this.client.autoAnswerDelayTime;
|
|
33966
|
+
}
|
|
33923
33967
|
setAnswered(channelId, timestamp, member) {
|
|
33924
33968
|
this.state = ConversationState.Active;
|
|
33925
33969
|
this.answeredAt = timestamp;
|
|
33926
33970
|
this.channelId = channelId;
|
|
33971
|
+
if (this._autoAnswerTimerId) {
|
|
33972
|
+
clearTimeout(this._autoAnswerTimerId);
|
|
33973
|
+
this._autoAnswerTimerId = null;
|
|
33974
|
+
}
|
|
33927
33975
|
this.member = wrapChannelMember(member);
|
|
33928
33976
|
this.inviteId = null; // deleted in DB
|
|
33929
33977
|
}
|
|
@@ -34039,6 +34087,17 @@ class Conversation {
|
|
|
34039
34087
|
cause: _cause,
|
|
34040
34088
|
});
|
|
34041
34089
|
}
|
|
34090
|
+
async joinDelay() {
|
|
34091
|
+
if (this.autoAnswered) {
|
|
34092
|
+
return;
|
|
34093
|
+
}
|
|
34094
|
+
this.autoAnswered = true;
|
|
34095
|
+
this._autoAnswerTimerId = setTimeout(async () => {
|
|
34096
|
+
if (!this.answeredAt) {
|
|
34097
|
+
await this.join();
|
|
34098
|
+
}
|
|
34099
|
+
}, this.autoAnswerDelay);
|
|
34100
|
+
}
|
|
34042
34101
|
async join() {
|
|
34043
34102
|
if (!this.inviteId)
|
|
34044
34103
|
throw new Error('This conversation is joined');
|