-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceDeskCallback.ts
106 lines (92 loc) · 3.76 KB
/
serviceDeskCallback.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/**
* (C) Copyright IBM Corp. 2020.
*
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/MIT
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
*/
import { ServiceDeskErrorInfo } from './errors';
import { MessageResponse } from './message';
import { AgentProfile } from './profiles';
/* eslint-disable camelcase */
/**
* Any code that's using a service desk must implement this interface to provide this callback functions that the
* service desk can use to send information back to the calling code when the information becomes available.
*/
interface ServiceDeskCallback {
/**
* Sends updated availability information to the chat widget for a user who is waiting to be connected to an
* agent. This may be called at any point while waiting for the connection to provide newer information.
*
* @param availability The availability information to display to the user.
*/
updateAgentAvailability(availability: AgentAvailability): void;
/**
* Informs the chat widget that an agent has joined the chat.
*
* @param profile The meta data about the agent.
*/
agentJoined(profile: AgentProfile): void;
/**
* Informs the chat widget that the agent has read all the messages that have been sent to the service desk.
*/
agentReadMessages(): void;
/**
* Tells the chat widget if an agent has started or stopped typing.
*
* @param isTyping If true, indicates that the agent is typing. False indicates the agent has stopped typing.
*/
agentTyping(isTyping: boolean): void;
/**
* Sends a message to the chat widget from an agent.
*
* @param message The message to display to the user.
* @param agentID The ID of the agent who is sending the message.
*/
sendMessageToUser(message: MessageResponse, agentID: string): void;
/**
* Informs the chat widget that a transfer to another agent is in progress. The agent profile information is
* optional if the service desk doesn't have the information available. This message simply tells the chat widget
* that the transfer has started. The service desk should inform the widget when the transfer is complete by
* sending a {@link agentJoined} message later.
*/
beginTransferToAnotherAgent(profile?: AgentProfile): void;
/**
* Informs the chat widget that the agent has left the conversation. This does not end the conversation itself,
* rather the only action that occurs is the visitor receives the agent left status message. If the user sends
* another message, it is up to the service desk to decide what to do with it.
*/
agentLeftChat(): void;
/**
* Informs the chat widget that the agent has ended the conversation.
*/
agentEndedChat(): void;
/**
* Sets the state of the given error type.
*
* @param errorInfo Details for the error whose state is being set.
*/
setErrorStatus(errorInfo: ServiceDeskErrorInfo): void;
}
/**
* Information about the current availability of an agent while a user is waiting to be connected. If these are not set
* the web chat will provide generic messaging letting the user know that they will reach a live agent as soon as
* possible.
*/
interface AgentAvailability {
/**
* Number of users ahead in the queue.
*/
position_in_queue?: number;
/**
* Estimated wait time in minutes.
*/
estimated_wait_time?: number;
}
export { AgentAvailability, AgentProfile, ServiceDeskCallback };