Select your cookie preferences

We use essential cookies and similar tools that are necessary to provide our site and services. We use performance cookies to collect anonymous statistics, so we can understand how customers use our site and make improvements. Essential cookies cannot be deactivated, but you can choose “Customize” or “Decline” to decline performance cookies.

If you agree, AWS and approved third parties will also use cookies to provide useful site features, remember your preferences, and display relevant content, including relevant advertising. To accept or decline all non-essential cookies, choose “Accept” or “Decline.” To make more detailed choices, choose “Customize.”

AWS Logo
Menu
Amazon Connect 3rd Party Application Integration

Amazon Connect 3rd Party Application Integration

How to implement screen pop in customer application from Agent Workspace

Anatoly Klepikov
Amazon Employee
Published Oct 4, 2024
This article describes how to implement Contact Flow in Amazon Connect, so it will trigger screen pop in an external application with caller details, when contact center agent receives voice or chat communication request.
Overview
Amazon Connect has a number of CTI Adapters for native integration with market leaders, such as Salesforce, Zendesk, ServiceNow. When this approach covers large portion of customer needs, it does not cover cases where integration is needed with customer application or applications where such CTI Adapter does not exist.
Amazon Connect has recently introduced two new features, which allow to customize web interface of the Agent Workspace application making it tailored to the business process relevant to the specific customer inquiry, for launching external applications and navigating to the customer record in it. This approach fill in the gap mentioned above. In addition to the screen pop this approach also allows to take actions, such as provide caller self-service capabilities in an external application, such as make an inquiry, create or update case or ticket.
The key benefits of this solution are:
· Ability to integrate with one or more external applications, with which there is no native integrations from Amazon Connect. It is not uncommon scenario where agent must use use more than one application for handling different scenario, such as booking, billing, etc.
· Access to Amazon Connect features available in Agent Workspace
Solution description
The following AWS Services are used:
· Amazon Connect to provide the communication channel to the customer via voice or chat.
· AWS Lambda for integration with third party applications, such as inquiry customer record id used for the screen pop.
· AWS S3 for hosting web pages of third-party application. Alternatively, any HTTP Web Server or Application Server can be used, which can produce HTML Output. The requirements for 3rd party application apply, such as HTTPS access and ability to host in iFrame.
· Amazon CloudFront for providing HTTPS web access to 3rd party application web pages stored in AWS S3 bucket.
The solution can easily be expanded by leveraging other AWS services, for example Amazon Lex for implementing self-service voice/chat-bot.
NOTE: Because 3rd party application hosted within Amazon Connect Agent Workspace requires to be iFrame compatible (can be hosted in iFrame), a typical scenario for launching an external application, which is not iFrame compatible would be to implement screen pop (open in an external window) of this application, such as Salesforce or Zendesk, from within 3rd party application triggered by Javascript or hyperlink.
Below is the architecture diagram for possible implementation of the solution:
Image not found
Solution Architecture
Customer calls in or initiates chat (1), which launches Contact Flow in Amazon Connect. This Contact Flow captures customer phone number or email address or other identity data, which later will be used for querying customer details (2). After capturing customer identity data Contact Flow launches Lambda function to identify customer and retrieve their data by invoking API request, or multiple requests, into the third-party application, or applications (3). Based on the retried data Contact Flow can make decision whether customer is identified and if necessary offer an authentication. Once the decision has been made that the call is legitimate, customer data, such as customer record id or URL in external system, are attached to the call as Contact Attributes (4). Call is than placed into a queue and routed to an appropriate agent based on the routing logic, such as agent with appropriate skills (5). An agent, whose status is Available, receives the call and Agent Workspace application loads the web form, which contains the data related to this call. This web form also allows to trigger screen pop in the third-party application using customer data passed as Contact Attributes (6). This triggering can be implemented as hyperlink or Javascript within 3rd party application loaded within Amazon Connect Agent Workspace. Code example showing how to implement 3rd party application with hyperlink to launch an external application showing customer data is presented further in this article.
Below is an example of Amazon Connect Contact Flow receiving an initial customer call or chat (1), retrieving customer data (2) and executing AWS Lambda function (3):
Image not found
Amazon Connect Main Contact Flow
Below is an example of Lambda code simulating data retrieval from an external application (this code is an example for demonstration purposes only, reader is expected to modify it to accommodate their needs):
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
import json

def lambda_handler(event, context):
# TODO implement
CustomerPhoneInput = event['Details']['Parameters']['CustomerPhoneInput']
CustomePhoneReturn = CustomerPhoneInput.strip()
if(not CustomePhoneReturn.startswith("+")): CustomePhoneReturn = "+" + CustomePhoneReturn
print("CustomePhoneReturn=", CustomePhoneReturn)

# customer email address or phone number can be used for identifying customer record in the external application
ContactPhoneNumberOrEmail = CustomePhoneReturn
print("ContactPhoneNumberOrEmail=", ContactPhoneNumberOrEmail)

# Using 3rd party API query customer data and retrieve customer name for personal greeting
Name = 'Bob Brown'
print("Name=", Name)

# Using external application API query customer data and generated URL for screen pop based on the customer id
contactUrlPath = 'https://XXXXX'
print("contactUrlPath=", contactUrlPath)

# you can control screen pop layout
contactUrlWidth = '1500'
print("contactUrlWidth=", contactUrlWidth)

# you can control screen pop layout
contactUrlHeight = '1000'
print("contactUrlHeight=", contactUrlHeight)

return {
'statusCode': 200,
'CustomePhoneReturn': CustomePhoneReturn,
'Name': Name,
'ContactPhoneNumberOrEmail': ContactPhoneNumberOrEmail,
'contactUrlPath': contactUrlPath,
'contactUrlWidth': contactUrlWidth,
'contactUrlHeight': contactUrlHeight
}
For launching web form in Amazon Connect Agent Workspace application we use Amazon Connect feature Step-by-step guide. Screen below shows how to set up Amazon Connect Contact Flow for using Step-by-step guide:
Image not found
Amazon Connect Main Contact Flow
Amazon Connect Contact Flow used by Step-by-step guide launches the view where web form will be hosted. The screen below shows how it may look like:
Image not found
Amazon Connect Step-by-step Contact Flow
The view will receive parameters, used for launching application, where application one of widgets in Step-by-step guide GUI designer. Below is an example how the parameters can be passed as JSON:
{"AppIdentifier":"Popup2cloudFront","Path":""}
AppIdentifier – this is the name of 3rd party application, which will be launched within Step-by-step application widget.
Below is the designer view of Step-by-step guide showing application widget where 3rd party application will be launched (4)
Image not found
Amazon Connect Step-by-step View
Below is an example how 3rd party application, which code is presented above in this article, can be configured in Amazon Connect. This 3rd party application will be loaded in Amazon Connect Agent Workspace when call is received by an agent and allow agent to launch an external application with customer data by clicking the hyperlink:
Image not found
Amazon Connect 3rd Party Application Configuration
In this example Popup2cloudFron – is the name of application pointing to the Amazon CloudFront instance referencing to AWS S3 bucket with web pages for 3rd party application (5).
Below is an example AWS S3 bucket containing 3rd party application code generated from of REACT project:
Image not found
3rd Party Application REACT code in Amazon S3 Bucket
When agent answers the call, they can initiate screen pop in external application as shown below (6):
Image not found
Amazon Connect Agent Workspace executing screen pop

 Below is an example of 3rd party application code executed in iFrame within Amazon Connect Agent Workspace allowing to launch an external application with customer data by clicking hyperlink. (this code is an example for demonstration purposes only, reader is expected to modify it to accommodate their needs):
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
import { useState, useEffect } from 'react';
import './App.css';
import Banner from './assets/3PAppsBanner.png'
import { AmazonConnectApp, AppContactScope } from "@amazon-connect/app";
import { VoiceClient } from "@amazon-connect/voice";
import { ContactClient, AgentClient, AgentStateChangedEventData, ContactStartingAcwEventData } from "@amazon-connect/contact";
import Cards from "@cloudscape-design/components/cards";
import Box from "@cloudscape-design/components/box";
import SpaceBetween from "@cloudscape-design/components/space-between";
import Button from "@cloudscape-design/components/button";
import ExpandableSection from "@cloudscape-design/components/expandable-section";
import Alert from "@cloudscape-design/components/alert";
import StatusIndicator from "@cloudscape-design/components/status-indicator";
import Link from "@cloudscape-design/components/link";

var permissions = [];

const connectApp = AmazonConnectApp.init({
onCreate: (event) => {
const { appInstanceId } = event.context;
const { contactScope } = event.context;
console.log('App initialized: ', appInstanceId);
console.log("EVENT", event)
console.log("length", event.context.appConfig.permissions.length)
permissions = event.context.appConfig.permissions;
},
onDestroy: (event) => {
console.log('App being destroyed');
},
});

function App() {

// INSTANTIATING STATE
const [agentName, setAgentName] = useState("");
const [agentState, setAgentState] = useState("");
const [agentARN, setAgentARN] = useState("");
const [agentRoutingProfile, setAgentRoutingProfile] = useState("");
const [agentChannelConcurrency, setAgentChannelConcurrency] = useState({CHAT:"", VOICE:"", TASK:""});
const [stateContactId, setStateContactId] = useState("");
const [attributes, setAttributes] = useState(null);
const [contactType, setContactType] = useState("");
const [contactStateDuration, setContactStateDuration] = useState("");
const [contactQueue, setContactQueue] = useState("");
const [contactInitialContactId, setContactInitialContactId] = useState("")
const [contactPhoneNumberOrEmail, setContactPhoneNumberOrEmail] = useState("")
const [contactPopupLink, setContactPopupLink] = useState("")
const [contactQueueTimestamp, setContactQueueTimestamp] = useState("");
const [acw, setACW] = useState(null)
const [firstAlertVisible, setFirstAlertVisible] = useState(true);
const [secondAlertVisible, setSecondAlertVisible] = useState(true);

// INSTANTIATING AGENT/CONTACT CLIENTS
const agentClient = new AgentClient();
const contactClient = new ContactClient();
const voiceClient = new VoiceClient();

var showPopupLink = "javascript:window.open('https://XXXXXXX')";

// AGENT EVENT LISTENERS
agentClient.onStateChanged(fetchAgentData);

// CONTACT EVENT LISTENERS
contactClient.onStartingAcw(fetchContactData);
contactClient.onMissed(fetchContactData);
contactClient.onDestroyed(fetchContactData);

// AGENT DATA HANDLER
async function fetchAgentData(AgentStateChangedEventData) {

const contactUrlHeightValue = '1000';

const contactUrlPath = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlPath');
const contactUrlPathValue = contactUrlPath.value;
console.log(">>>>>>>>>>contactUrlPath", contactUrlPathValue);

const contactUrlWidth = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlWidth');
const contactUrlWidthValue = contactUrlWidth.value;
console.log(">>>>>>>>>>contactUrlWidth", contactUrlWidthValue);

//const contactUrlHeight = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlHeight');
//const contactUrlHeightValue = contactUrlHeightvalue.value;
console.log(">>>>>>>>>>contactUrlHeight", contactUrlHeightValue);


const attributeContactPopupLink = "javascript:window.open('" + contactUrlPathValue + "','newwindow','width=" + contactUrlWidthValue + ",height=" + contactUrlHeightValue + "')";
console.log(">>>>>>>>>>attributeContactPopupLink", attributeContactPopupLink);
setContactPopupLink(attributeContactPopupLink);

// GET AGENT ARN
const arn = await agentClient.getARN();
setAgentARN(arn); // SET STATE

// GET AGENT NAME
const name = await agentClient.getName();
setAgentName(name) // SET STATE

// GET AGENT STATE
const currentState = await agentClient.getState();
setAgentState(currentState.state.name) // SET STATE

// SAMPLE RESPONSE ON getState
// {
// "state": {
// "agentStateARN":"arn:aws:connect:us-XXXXXXXXXXXXXXXXXXXXX",
// "type":"offline",
// "name":"Offline",
// "startTimestamp":"2024-01-11T22:31:33.270Z",
// "availabilityState":"Offline"
// }
// }

// GET AGENT ROUTING PROFILE
const routingProfile = await agentClient.getRoutingProfile();
setAgentRoutingProfile(routingProfile.routingProfile.name);

// GET AGENT CHANNEL CONCURRENCY
const channelConcurrency = await agentClient.getChannelConcurrency();
setAgentChannelConcurrency((prevState) => {
return({
...prevState,
VOICE: `${channelConcurrency.channelConcurrency.VOICE}`
});
});
setAgentChannelConcurrency((prevState) => {
return({
...prevState,
CHAT: channelConcurrency.channelConcurrency.CHAT
});
});
setAgentChannelConcurrency((prevState) => {
return({
...prevState,
TASK: channelConcurrency.channelConcurrency.TASK
});
});

// OTHER AGENT DATA
const extension = await agentClient.getExtension();
const dialableCountries = await agentClient.getDialableCountries();
}

// CONTACT DATA HANDLER
async function fetchContactData(ContactStartingAcwEventData) {
console.log("TEST", ContactStartingAcwEventData)
// try {
// const attributesList = await contactClient.getAttributes(AppContactScope.CurrentContactId, '*');
// setAttributes(attributesList)
// console.log("ATTRIBUTES", attributesList)

// }
// catch(err) {
// console.log("ERROR", err)
// }
// GET CONTACT ATTRIBUTES, * MEANS ALL
const attributesList = await contactClient.getAttributes(AppContactScope.CurrentContactId, '*');
setAttributes(attributesList)
console.log("ATTRIBUTES", attributesList)

const attributeContactPhoneNumberOrEmail = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'ContactPhoneNumberOrEmail');
const attributeContactPhoneNumberOrEmailvalue = attributeContactPhoneNumberOrEmail.value;
console.log(">>>>>>>>>>attributeContactPhoneNumberOrEmail", attributeContactPhoneNumberOrEmailvalue);
setContactPhoneNumberOrEmail(attributeContactPhoneNumberOrEmailvalue);

//const contactUrlPathValue = 'https://XXXXXXXXXXXXXXXX';
//const contactUrlWidthValue = '1500';
const contactUrlHeightValue = '1000';

const contactUrlPath = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlPath');
const contactUrlPathValue = contactUrlPath.value;
console.log(">>>>>>>>>>contactUrlPath", contactUrlPathValue);

const contactUrlWidth = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlWidth');
const contactUrlWidthValue = contactUrlWidth.value;
console.log(">>>>>>>>>>contactUrlWidth", contactUrlWidthValue);

//const contactUrlHeight = await contactClient.getAttribute(AppContactScope.CurrentContactId, 'contactUrlHeight');
//const contactUrlHeightValue = contactUrlHeightvalue.value;
console.log(">>>>>>>>>>contactUrlHeight", contactUrlHeightValue);


const attributeContactPopupLink = "javascript:window.open('" + contactUrlPathValue + "','newwindow','width=" + contactUrlWidthValue + ",height=" + contactUrlHeightValue + "')";
console.log(">>>>>>>>>>attributeContactPopupLink", attributeContactPopupLink);
setContactPopupLink(attributeContactPopupLink);

// GET INTIAL CONTACT ID, ONLY WORKS ON TRANSFERS
const initialContactId = await contactClient.getInitialContactId(AppContactScope.CurrentContactId)
setContactInitialContactId(initialContactId);
console.log("ICI", initialContactId)

// GET TYPE
const type = await contactClient.getType(AppContactScope.CurrentContactId);
setContactType(type);
console.log("T", type)

// GET STATE DURATION
const stateDuration = await contactClient.getStateDuration(AppContactScope.CurrentContactId);
setContactStateDuration(stateDuration)
console.log("SD", stateDuration)

// GET QUEUE
const queue = await contactClient.getQueue(AppContactScope.CurrentContactId);
if (queue.queue.name == null) {
setContactQueue(`Agent Queue ${queue.queue.queueARN}`)
console.log("HERE QUEUE ARN", queue.queue.queueARN)
} else {
setContactQueue(queue.queue.name)
console.log("HERE2", queue.queue.name)
}

// GET QUEUE TIMESTAMP
const queueTimestamp = await contactClient.getQueueTimestamp(AppContactScope.CurrentContactId);
setContactQueueTimestamp(JSON.stringify(queueTimestamp))
console.log("QUEUE TIMESTAMP", queueTimestamp)
}

// OBTAIN CURRENT AGENT AND CURRENT CONTACT VALUES
useEffect(() => {
fetchAgentData()
fetchContactData()
}, []);


return (
<div className="App">

<img src={Banner} width="100%" align="center" alt="Third-party applications for Amazon Connect" />

{ permissions.length === 0 ?
<div className="Alert">
<Alert
dismissible
onDismiss={() => {
setFirstAlertVisible(false)
}}
visible={firstAlertVisible}
statusIconAriaLabel="Error"
type="error"
header="Permissions have not been set for this App Config. "
>
You must explicitly give third-party applications permissions to Amazon Connect data. <Link external href="https://docs.aws.amazon.com/connect/latest/adminguide/3p-apps-events-requests.html">Learn more here</Link>.
</Alert>
</div>
:
""
}

{ (permissions.length > 0 && permissions.length < 6) ?
<div className="Alert">
<Alert
dismissible
onDismiss={() => {
setSecondAlertVisible(false)
}}
visible={secondAlertVisible}
statusIconAriaLabel="Warning"
type="warning"
header="There are missing permissions for this App Config."
>
If your application attempts to subscribe to an event or make a request for data that it does not have permission for, your application may not function as intended. <Link external href="https://docs.aws.amazon.com/connect/latest/adminguide/3p-apps-events-requests.html">Learn more here</Link>.
</Alert>
</div>
:
""
}

<div className="Boxes">
<Cards
ariaLabels={{
itemSelectionLabel: (e, t) => `select ${t.name}`,
selectionGroupLabel: "Item selection"
}}
cardDefinition={{
header: item => (
(item.type === "N/A" || item.type === "No active contact" || item.type === "NONE")
?
<StatusIndicator type="error">Error</StatusIndicator>
:
<StatusIndicator>Success</StatusIndicator>
),
sections: [
{
id: "description",
header: "",
content: item => (<span style={{fontWeight:700}}> {item.description} </span>)
},
{
id: "type",
header: "",
content: item => item.type
}
]
}}
cardsPerRow={[
{ cards: 1 },
{ minWidth: 200, cards: 5 }
]}
items={[
{
name: "agentARN",
alt: "Agent ARN",
description: "Current agent ARN",
type: agentARN === "" ? "N/A" : agentARN
},
{
name: "agentName",
alt: "Agent Name",
description: "Current agent name",
type: agentName === "" ? "N/A" : agentName
},
{
name: "agentState",
alt: "Agent State",
description: "Current agent state",
type: agentState === "" ? "N/A" : agentState
},
{
name: "routingProfile",
alt: "Agent Routing Profile",
description: "Current agent routing profile",
type: agentRoutingProfile === "" ? "N/A" : agentRoutingProfile
},
{
name: "channelConcurrency",
alt: "Agent Channel Concurrency",
description: "Current agent channel concurrency limits",
type: agentChannelConcurrency.CHAT === "" ? "N/A" : `VOICE: ${agentChannelConcurrency.VOICE}, CHAT: ${agentChannelConcurrency.CHAT}, TASK: ${agentChannelConcurrency.TASK}`
},
{
name: "contactType",
alt: "Contact Type",
description: "Type of contact / channel",
type: contactType === "" ? "No active contact" : contactType
},
{
name: "contactQueue",
alt: "Contact Queue",
description: "Queue current contact was routed through",
type: contactQueue == "" ? "No active contact" : contactQueue
},
{
name: "Item 8",
alt: "Queue Timestamp",
description: "Timestamp associated with when the contact was placed in the queue",
type: contactQueueTimestamp === "" ? "No active contact" : (contactQueueTimestamp === "null" ? "Response received, but no timestamp available" : contactQueueTimestamp)
},
{
name: "Item 8",
alt: "State Duration",
description: "The duration of the contact state in milliseconds relative to local time",
type: contactStateDuration == "" ? "No active contact" : `${contactStateDuration} milliseconds`
},
{
name: "initialContactId",
alt: "Initial Contact ID",
description: "Initial contact ID, if transferred or none if this is not an internal Connect transfer",
type: contactInitialContactId === "" ? "No active contact" : (contactInitialContactId === null ? "NOT AN INTERNAL TRANSFER" : contactInitialContactId)
},
{
name: "contactPhoneNumberOrEmail",
alt: "contactPhoneNumberOrEmail",
description: "contactPhoneNumberOrEmail",
type: contactPhoneNumberOrEmail === "" ? "No active contact" : (contactPhoneNumberOrEmail === null ? "NOT AN INTERNAL TRANSFER" : contactPhoneNumberOrEmail)
}
]}
loadingText="Loading resources"
empty={
<Box
margin={{ vertical: "xs" }}
textAlign="center"
color="inherit"
>
<SpaceBetween size="m">
<b>No resources</b>
<Button>Create resource</Button>
</SpaceBetween>
</Box>
}
/>
</div>

{ attributes === null ?
<div>
</div>
:
<div className='contactAttributes'>
<ExpandableSection headerText="Contact Attributes">
{JSON.stringify(attributes)}
</ExpandableSection>
</div>
}

<br/><br/>
<a href={showPopupLink}>Customer CRM - main page</a>
<br/><br/>

<a href={contactPopupLink}>Customer CRM - when there is a call</a>

</div>
);
}

export default App;
Summary
In this post we described how to implement screen pop in an external application and its benefits.
References
· Cloudscape (Amazon Connect Agent Workspace follows patterns of this framework)
Tags
The team
Image not found
The Team

 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

2 Comments

Log in to comment