-
Notifications
You must be signed in to change notification settings - Fork 0
/
serviceDeskTemplate.ts
109 lines (97 loc) · 4.57 KB
/
serviceDeskTemplate.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
107
108
109
/**
* (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.
*
*/
/**
* Copy and paste this file into a new folder to get started.
*/
import { MessageRequest, MessageResponse } from '../types/message';
import { User } from '../types/profiles';
import { ServiceDesk, ServiceDeskFactoryParameters, ServiceDeskStateFromWAC } from '../types/serviceDesk';
import { AgentProfile, ServiceDeskCallback } from '../types/serviceDeskCallback';
/**
* This class returns startChat, endChat, sendMessageToAgent, updateState, userTyping, userReadMessages and
* areAnyAgentsOnline to be exposed to web chat through src/buildEntry.ts.
*/
class ServiceDeskTemplate implements ServiceDesk {
agentProfile: AgentProfile;
callback: ServiceDeskCallback;
user: User;
sessionID: string;
constructor(parameters: ServiceDeskFactoryParameters) {
this.callback = parameters.callback;
this.user = { id: '' };
this.sessionID = '';
}
/**
* Instructs the service desk to start a new chat. This should be called immediately after the service desk
* instance has been created. It will make the appropriate calls to the service desk and begin communicating back
* to the calling code using the callback produce to the instance. This may only be called once per instance.
*
* @param connectMessage The original server message response that caused the connection to an agent. It will
* contain specific information to send to the service desk as part of the connection. This can includes things
* like a message to display to a human agent.
* @returns Returns a Promise that resolves when the service desk has successfully started a new chat. This does
* not necessarily mean that an agent has joined the conversation or has read any messages sent by the user.
*/
async startChat(connectMessage: MessageResponse): Promise<void> {}
/**
* Tells the service desk to terminate the chat.
*
* @returns Returns a Promise that resolves when the service desk has successfully handled the call.
*/
async endChat(): Promise<void> {}
/**
* Sends a message to the agent in the service desk.
*
* @param message The message from the user.
* @param messageID The unique ID of the message assigned by the widget.
* @returns Returns a Promise that resolves when the service desk has successfully handled the call.
*/
async sendMessageToAgent(message: MessageRequest, messageID: string): Promise<void> {}
/**
* Informs the service desk of a change in the state of the web chat that is relevant to the service desks. These
* values may change at any time.
*
* @param state The current values of pieces of state from the main chat.
*/
updateState(state: ServiceDeskStateFromWAC): void {}
/**
* Tells the service desk if a user has started or stopped typing.
*
* This functionality is not currently implemented in the web chat widget.
*
* @param isTyping If true, indicates that the user is typing. False indicates the user has stopped typing.
* @returns Returns a Promise that resolves when the service desk has successfully handled the call.
*/
async userTyping(isTyping: boolean): Promise<void> {}
/**
* Informs the service desk that the user has read all the messages that have been sent by the service desk.
*
* This functionality is not currently implemented in the web chat widget.
*
* @returns Returns a Promise that resolves when the service desk has successfully handled the call.
*/
async userReadMessages(): Promise<void> {}
/**
* Checks if any agents are online and ready to communicate with the user.
*
* @param connectMessage The message that contains the transfer_info object that may be used by the service desk
* so it can perform a more specific check.
* @returns True if some agents are available or false if no agents are available. This may also return null which
* means the availability status of agents is unknown or the service desk doesn't support this information.
*/
async areAnyAgentsOnline(connectMessage: MessageResponse): Promise<boolean | null> {
return null;
}
}
export { ServiceDeskTemplate };