
Embedding Amazon Connect Voice + Chat into ServiceNow
Enable both voice and chat from Amazon Connect into any ServiceNow configurable workspace, with AI assistants included
Series: ServiceNow on AWS (9 articles)
- …
- 8Embedding Amazon Connect Voice + Chat into ServiceNow This article
ServiceNow's published integration brings Connect voice, but not chat, into a ServiceNow workspace. This document shows how to bring in both, add screen pops that identify the customer and show ticket history, give human operators the Connect agent assist AI, and record chats on a ServiceNow ticket.
In summary, ServiceNow Voice is disabled and replaced by the Connect Contact Control Panel (CCP), with voice, chat and agent assist, plus links to customer and ticket history in ServiceNow.
This does not use the ServiceNow Contact Center Integration Framework (CCIF), the server-side API for chat integrations. Connect lacks the server-side APIs to make that straightforward, so this is a client-side integration customers can configure themselves. CCIF records full chats in ServiceNow; here Connect records them, they can be reviewed from ServiceNow, and optionally copied to a ticket. Pros and cons versus CCIF are in the appendix.
Test every step in sub-prod first; menu names and roles vary by release.
1. Overview & Architecture
What you will build
Your agents (human operators) will handle customer calls and chats inside a ServiceNow workspace (e.g. ITSM, CSM, ITOM). The Connect agent workspace sits in a ServiceNow panel, and the matching record opens when a contact arrives.
• One panel for both channels: voice, chat and tasks via the Connect agent workspace (/agent-app-v2/).
• Connect assistant included: Amazon Q in Connect (AI recommendations and agent Q&A) on the same page.
• Screen pop: a short script opens the right record for new contacts.
• Low code: mostly configuration plus one small script.
How it works
All media (voice and chat) stays in Connect. ServiceNow only displays the Connect page and reacts to contact events; its servers never carry voice or chat traffic.
Component | Lives in | Job |
|---|---|---|
Chat widget / phone number | Connect | Customer starts a chat or call |
Contact flows, queues, routing | Connect | Pick the agent |
Agent workspace (/agent-app-v2/) | Connect, shown in a ServiceNow panel | Agent answers calls and chats |
Screen pop script | ServiceNow (UI Builder) | Opens the matching record |
Incidents, cases, contacts | ServiceNow | Record keeping and workflow |

What you gain and what you give up
You gain | You give up |
|---|---|
Voice and chat in one place in ServiceNow | No ServiceNow-native look (agents see Connect) |
The Connect assistant (Q in Connect) | No auto incident/case creation unless added |
No ServiceNow Voice plugin or license | No deep features such as AWA for chat |
Very little code to maintain | Transcripts not stored in ServiceNow by default |
IMPORTANT One Connect session per agent: never run this panel alongside the ServiceNow Voice hidden CCP. Part B turns ServiceNow Voice off. |
|---|
2. Prerequisites & Checklist
ServiceNow access
• Admin role in a sub-prod instance.
• UI Builder access (ui_builder_admin or admin).
• A workspace in use (ITSM, CSM, ITOM or similar) on Next Experience.
AWS / Connect access
• A Connect instance with voice and chat working (chat widget on your website or portal).
• Connect admin login (Admin security profile) and AWS console access to the instance.
• Optional: Amazon Q in Connect enabled, for the AI assistant panel.
Information to collect
Item | Example | Where to find it |
|---|---|---|
Connect instance URL | https://mycompany.my.connect.aws | AWS console > Connect > instance |
ServiceNow instance URL | https://mycompany.service-now.com | Browser address bar |
Workspace name | Service Operations Workspace | ServiceNow > Workspaces |
Connect login method | Connect users or SAML/SSO | AWS console > instance > Identity management |
Customer ID in flows | email, phone, or sys_id | Flows / pre-chat form |
TIP Note these values; you will paste them in several places. |
|---|
3. Step A — Configure Connect
Step A1: Add ServiceNow to Approved Origins
Lets Connect appear inside ServiceNow pages; without it the panel is blank or refuses to connect.
1. Open Connect in the AWS console.
2. Click your instance alias (not the Access URL).
3. Choose Approved origins (sometimes under Application integration).
4. Click Add domain and enter your ServiceNow URL (e.g. https://mycompany.service-now.com ): https, no trailing slash.
5. Add any custom ServiceNow domain too.
6. Click Add domain.
Step A2: Enable chat and set routing concurrency
Agents need a routing profile that allows chats as well as calls.
1. Sign in to the Connect admin site (instance URL) as admin.
2. Open Users > Routing profiles > your agents' profile.
3. Under Channel settings, tick Voice and Chat; set max chats per agent (e.g. 2 or 3).
4. Ensure your chat flow's queues are in this profile.
5. Save.
Step A3: Agent security profile permissions
1. Open Users > Security profiles > the agent profile (e.g. Agent).
2. Under Contact Control Panel (CCP), allow Access CCP.
3. For Q in Connect, under Agent Applications allow Connect assistant - Access.
4. Optionally allow Customer Profiles - View.
5. Save.
Step A4: Pass customer attributes in your flows
Screen pop needs a search key. Voice includes the caller number; chats do not, so add a customer identifier attribute.
1. Ensure the pre-chat form (or Lex bot) collects the customer email (or other ID).
2. In the inbound chat flow, add a Set attributes block: user-defined customerEmail = the form value.
3. Optionally, after a Lambda lookup, set snSysId (record sys_id) and snTable (e.g. incident, customer_contact).
4. Publish the flow.
NOTE Attribute names are case-sensitive; use the same names in the Part D script. |
|---|
4. Step B — Turn Off ServiceNow Voice (If Installed)
If ServiceNow Voice (sn_cti_amzn_cct) or another OpenFrame phone is installed, it loads its own hidden Connect panel. Two sessions per agent cause misrouted rings, missed chats or logouts. Skip if never installed.
Step B1: Check whether it is installed
1. In ServiceNow, open System Definition > Plugins (search Plugins in the navigator) or the Application Manager.
2. Search Connect, ServiceNow Voice, CTI and OpenFrame.
3. Note installed items, commonly sn_cti_core, sn_cti_amzn_cct, sn_cti_ux, sn_cti_itsm_cnt, sn_cti_csm_cnt.
4. A phone/interaction icon in the workspace header usually means OpenFrame is active.
Step B2: Remove the CTI and OpenFrame roles from agents (reversible)
Phone controls only show for users with these roles; removing them is the safest first step.
1. Open User Administration > Groups > your agent group.
2. On the Roles tab, find roles such as sn_openframe_user and ServiceNow Voice agent roles (names usually contain cti or voice).
3. Click Edit, move those roles out of the selected list, and Save.
4. Check a test agent's Roles tab for directly granted roles.
NOTE Role names vary by release. Search sys_user_role for "openframe", "cti" and "voice". |
|---|
Step B3: Deactivate the OpenFrame configuration
1. Open OpenFrame > Configurations (search OpenFrame in the navigator).
2. Open the Connect configuration (e.g. named Connect or ServiceNow Voice).
3. Uncheck Active and click Update.
4. Deactivate any other unused OpenFrame configurations.
Step B4 (optional): Deactivate the integration completely
If nobody uses ServiceNow Voice, ask your platform owner about deactivating or uninstalling the app; get approval, as it may affect reports or other teams.
Step B5: Verify there is only one Connect session
1. Sign in as a test agent (or Impersonate User).
2. Open the workspace; confirm there is no header phone icon.
3. Press F12; on Elements, search (Ctrl/Cmd+F) for my.connect.aws.
4. After Part C, only one Connect frame should be present.
5. Step C — Embed Connect in the Workspace with UI Builder
UI Builder edits workspace layouts. You will add a panel showing the Connect agent workspace.
Step C1: Open your workspace in UI Builder
1. Open UI Builder from the navigator.
2. Open your workspace (experience), e.g. Service Operations Workspace.
3. For a baseline experience, create a variant of the page when prompted; never edit the baseline, as upgrades may overwrite it.
4. Work in an update set (or correct app scope) so changes can move to production.
Step C2: Choose where the panel goes
The panel must stay loaded as agents move between records; a reload drops active calls and chats.
Option | Stays loaded? | Recommendation |
|---|---|---|
Side panel on the workspace shell | Usually | Best where supported |
Separate workspace page (tab) | While the tab is open | Simple fallback |
Panel on the record page | No, reloads per record | Avoid |
TIP Simplest reliable option: a dedicated "Contact Center" page kept open in its own tab while agents work records in others. |
|---|
Step C3: Add a page and an iframe component
1. Click + Create (or Add page), choose blank, name it Contact Center, path contact-center.
2. On the new page, click + Add content in the Content tree.
3. Search components for iframe (Next Experience has an Iframe component); if missing, ask your admin.
4. Drag it onto the page and fill it (Styles: width 100%, height ~800px or 100vh).
6. In any sandbox/allow setting, add: microphone; autoplay; clipboard-write (voice needs the microphone).
7. Save.
8. Add the page to workspace navigation (e.g. left sidebar) via experience Settings > Navigation or the app shell menu.
Step C4: Allow framing and microphone access
1. Confirm Step A1 (Approved Origins), the most common cause of a blank panel.
2. Ensure ServiceNow's content security/clickjacking properties (X-Frame-Options, Content-Security-Policy) allow https://*.my.connect.aws as a frame source; consult platform security first.
3. On first open, agents allow the browser microphone prompt.
4. IT can pre-approve the microphone for your ServiceNow URL via browser (e.g. Chrome) policy.
Step C5: Sign-in and SSO tips
• Connect user accounts: agents sign in inside the panel once; this normally works in the frame.
• SAML / SSO: many IdPs block login pages in frames. If the panel is blank or errors, sign in to Connect in a normal tab once, then return. Permanent fix: have your identity team allow the login flow and use the Connect login URL for your IdP.
• Agents must be signed in to only one Connect window; close other Connect tabs.
IMPORTANT With the iframe page open, test calls and chats while navigating; the panel must never reload during a contact. |
|---|
6. Step D — Enable Screen Pop
How the screen pop works
Connect Streams, a free JavaScript library, lets pages listen for events such as new contacts. This script catches voice or chat contacts, reads the Step A4 attributes, and opens the matching record in a new tab.
NOTE A plain iframe can't send events to ServiceNow. For screen pop, the hosting page must load Streams and start the panel through it; below, a small helper page replaces the iframe source. |
|---|
IMPORTANT The only part needing code: a pattern to adapt, not a product. Have a ServiceNow developer review it; test in sub-prod. |
|---|
Step D1: Create a UI Page that hosts Connect with Streams
1. Open System UI > UI Pages and click New.
2. Name it x_connect_agent (or similar); Category General.
3. Paste the HTML below into HTML, with your instance URLs.
4. Get connect-streams-min.js from the amazon-connect-streams GitHub releases and upload it as UI Script connect_streams (System UI > UI Scripts), or reference it as shown.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide">
<script src="connect_streams.jsdbx"></script>
<div id="ccp" style="width:100%;height:95vh;"></div>
<script>
var CONNECT_URL = 'https://mycompany.my.connect.aws';
connect.agentApp.initApp('ccp', 'ccp', CONNECT_URL + '/agent-app-v2/', {
ccpParams: { loginPopup: true, loginPopupAutoClose: true,
softphone: { allowFramedSoftphone: true } }
});
connect.contact(function (contact) {
contact.onConnecting(function () { pop(contact); });
contact.onIncoming(function () { pop(contact); });
});
function pop(contact) {
var a = contact.getAttributes();
var get = function (k) { return a[k] ? a[k].value : ''; };
var msg = { type: 'CONNECT_SCREEN_POP',
channel: contact.getType(), // 'voice' or 'chat'
table: get('snTable'), sysId: get('snSysId'),
email: get('customerEmail'),
phone: (contact.getActiveInitialConnection() || {getEndpoint:function(){return {phoneNumber:''};}})
.getEndpoint().phoneNumber };
window.parent.postMessage(msg, window.location.origin);
}
</script>
</j:jelly>
Step D2: Point the iframe at the new page
1. In UI Builder, open the Contact Center page.
2. Set the iframe Source URL to /x_connect_agent.do (your UI Page).
3. The helper page is on your ServiceNow domain, so Streams loads the Connect panel inside it; Approved Origins (Step A1) must include your ServiceNow URL.
4. Save.
Step D3: Open the record when a message arrives
Now add a client script on the Contact Center page that listens for the helper page's message and opens the record.
1. In UI Builder, select the Contact Center page.
2. In Client scripts (code icon, bottom left), click + Add; name it Connect screen pop.
3. Paste the script below.
4. Under page Events, attach it to the page Ready (loaded) event.
5. Save.
function handler({ api }) {
window.addEventListener('message', function (e) {
if (e.origin !== window.location.origin) return; // trust only ServiceNow
var d = e.data || {}; if (d.type !== 'CONNECT_SCREEN_POP') return;
var table = d.table, sysId = d.sysId;
if (!sysId) { // no direct id: search
var q = d.email ? 'email=' + d.email : 'phone=' + d.phone;
api.emit('NAV_ITEM_SELECTED', { route: 'list',
fields: { table: 'customer_contact' }, params: { query: q } });
return;
}
api.emit('NAV_ITEM_SELECTED', { route: 'record',
fields: { table: table || 'incident', sysId: sysId } });
});
}
NOTE NAV_ITEM_SELECTED is the standard Next Experience event to open a record or list in a new tab; some workspaces differ, so have your developer confirm. Declare it under Page > Events (dispatched events). |
|---|
Step D4: Map attributes to records
Attribute set | Script action | Result |
|---|---|---|
snSysId + snTable | Opens that record | Incident/case opens in a new tab |
customerEmail only | Opens a filtered list | Matching contacts list |
Phone number (voice) | Opens a filtered list | Matching contacts list |
Nothing | No screen pop | Agent searches manually |
TIP Most reliable: the flow calls a Lambda that finds the customer via the ServiceNow Table API and returns snSysId and snTable, so the exact record opens. See Part E. |
|---|
7. Step E — Lambda Lookup for Exact Screen Pop
Without a lookup, the Step D pop only opens a filtered list. Here a Lambda searches ServiceNow during the flow and returns the exact sys_id, so the right user or open incident opens, for voice and chat.
Step | Where | What happens |
|---|---|---|
1 | Connect flow | Sends email (chat) or phone (voice) to Lambda |
2 | AWS Lambda | Table API lookup of user and latest open incident |
3 | Connect flow | Saves snSysId and snTable attributes |
4 | ServiceNow | Part D script opens that record |
NOTE Needs AWS access (Lambda, secret) and a ServiceNow admin (integration user). Code is below. |
|---|
Step E1: Create a ServiceNow integration user
1. In ServiceNow, open User Administration > Users > New.
2. User ID svc_connect_lookup; a clear name such as Connect Lookup.
3. Tick Web service access only (no UI login).
4. Submit, reopen, Set Password, and store it safely for Step E2.
5. Add minimal roles to read sys_user and incident (e.g. itil or a custom read-only role); for CSM, read on customer_contact and sn_customerservice_case.
TIP Security may prefer OAuth; a developer can adapt the code to use an OAuth token. |
|---|
Step E2: Store the credentials in AWS Secrets Manager
1. In Secrets Manager (Connect's Region), click Store a new secret.
2. Choose Other type of secret with key/value pairs: instance = https://mycompany.service-now.com , user = svc_connect_lookup, password = the Step E1 password.
3. Name it connect/servicenow-lookup and finish.
4. Copy the secret ARN (for Step E3).
Step E3: Create the Lambda
1. In Lambda, click Create function.
2. Author from scratch: connect-servicenow-lookup, Python 3.12.
3. Click Create function.
4. In Code, replace lambda_function.py with the code below; Deploy.
5. Configuration > Environment variables: SN_SECRET_ARN = the Step E2 ARN.
6. Configuration > General configuration: Timeout 5 seconds (Connect waits at most 8).
7. Configuration > Permissions: on the role, allow secretsmanager:GetSecretValue on your secret ARN only.
import os, json, base64, urllib.request, urllib.parse
import boto3
SECRET_ARN = os.environ["SN_SECRET_ARN"]
sm = boto3.client("secretsmanager")
_creds = None
def creds():
global _creds
if _creds is None:
_creds = json.loads(sm.get_secret_value(SecretId=SECRET_ARN)["SecretString"])
return _creds
def sn_get(table, query, fields):
c = creds()
params = urllib.parse.urlencode({"sysparm_query": query,
"sysparm_fields": fields, "sysparm_limit": "1"})
url = c["instance"] + "/api/now/table/" + table + "?" + params
token = base64.b64encode((c["user"] + ":" + c["password"]).encode()).decode()
req = urllib.request.Request(url, headers={
"Authorization": "Basic " + token, "Accept": "application/json"})
with urllib.request.urlopen(req, timeout=3) as r:
return json.loads(r.read())["result"]
def lambda_handler(event, context):
p = event.get("Details", {}).get("Parameters", {})
email = (p.get("customerEmail") or "").strip()
phone = (p.get("customerPhone") or "").strip()
out = {"snFound": "false", "snTable": "", "snSysId": ""}
if not email and not phone:
return out
query = "email=" + email if email else "phone=" + phone + "^ORmobile_phone=" + phone
try:
users = sn_get("sys_user", query, "sys_id,name")
if not users:
return out
u = users[0]
out.update({"snFound": "true", "snCustomerName": u["name"],
"snTable": "sys_user", "snSysId": u["sys_id"]})
inc = sn_get("incident",
"caller_id=" + u["sys_id"] + "^active=true^ORDERBYDESCsys_updated_on",
"sys_id,number")
if inc:
out.update({"snTable": "incident", "snSysId": inc[0]["sys_id"],
"snIncidentNumber": inc[0]["number"]})
except Exception as e:
print("ServiceNow lookup failed:", e) # contact still routes normally
return out
NOTE Return values must be flat text (no lists or nested objects). It returns the latest open incident, else the user. If lookup fails, the contact still reaches an agent without an exact pop. |
|---|
IMPORTANT Phone formats must match: Connect sends +15551234567, so (555) 123-4567 in ServiceNow won't match. Agree one format or add number cleanup to the code. |
|---|
Step E4: Add the Lambda to Connect
1. In AWS, open Connect > your instance alias.
2. Choose Flows; scroll to AWS Lambda.
3. Select connect-servicenow-lookup; click Add Lambda Function.
Step E5: Call the Lambda in your flows
In both inbound chat and voice flows, before Transfer to queue:
1. Open the flow designer.
2. Add an Invoke AWS Lambda block before Transfer to queue.
3. Select connect-servicenow-lookup; Timeout 5 seconds; Response validation JSON.
4. Input parameters: customerEmail = $.Attributes.customerEmail (Step A4), customerPhone = $.CustomerEndpoint.Address.
5. Route both Success and Error onward so contacts never stick.
6. After Success, add Set attributes: snSysId = External snSysId, snTable = External snTable (optionally snIncidentNumber, snCustomerName).
7. Connect to Transfer to queue; Save and Publish.
TIP snSysId and snTable match the Part D script, so no changes are needed; when set, the exact record opens. |
|---|
Step E6: Test the lookup
1. In Lambda, Test with {"Details": {"Parameters": {"customerEmail": " a.real.user@yourcompany.com "}}}; expect snFound = true and a sys_id.
2. Chat with that email in the pre-chat form; the incident (or user) should open when the agent accepts.
3. Call from a number on a ServiceNow user; the same should happen.
4. If nothing pops, check the contact's attributes in Connect > Contact search; if snSysId is empty, check Lambda logs in CloudWatch.
Symptom | Likely cause | Fix |
|---|---|---|
Lambda error 401 | Wrong credentials or Web service access not set | Check Steps E1, E2 |
Lambda error 403 | User lacks read role | Grant read on sys_user, incident |
Lambda times out | ServiceNow slow or blocks AWS IPs | If IP allowlisting, use a NAT gateway with fixed IP |
snFound = false for known customer | Email/phone format differs | Compare values in both systems |
Attributes empty in contact search | Set attributes block missing or misplaced | Check Step E5 |
Step E7 (optional): Create an incident when none is open
By default the lookup only finds an open incident; otherwise the user record opens and Part F skips the transcript. Here the Lambda creates an incident, so every call and chat has one for the pop and transcript.
IMPORTANT Every contact without an open incident gets one, including wrong numbers and quick questions. Agree handling with your service desk lead first (e.g. a Contact Center category and a resolve/cancel process). |
|---|
1. Let the Step E1 user create incidents (itil covers this); read-only is no longer enough.
2. In the Step E3 Lambda, set environment variable AUTO_CREATE_INCIDENT = true (false disables it without code changes).
3. Replace lambda_handler with the version below (keep creds and sn_get), add sn_post, and Deploy.
4. Set the Lambda and Invoke block (Step E5) timeouts to 7 seconds: up to three ServiceNow calls; Connect waits at most 8.
5. In the Invoke block, add parameter channel = $.Channel (system attribute) to record call or chat.
6. Save and publish both flows.
AUTO_CREATE = os.environ.get("AUTO_CREATE_INCIDENT", "false") == "true"
def sn_post(table, body):
c = creds()
token = base64.b64encode((c["user"] + ":" + c["password"]).encode()).decode()
req = urllib.request.Request(c["instance"] + "/api/now/table/" + table,
data=json.dumps(body).encode(), method="POST", headers={
"Authorization": "Basic " + token, "Content-Type": "application/json",
"Accept": "application/json"})
with urllib.request.urlopen(req, timeout=3) as r:
return json.loads(r.read())["result"]
def lambda_handler(event, context):
p = event.get("Details", {}).get("Parameters", {})
email = (p.get("customerEmail") or "").strip()
phone = (p.get("customerPhone") or "").strip()
channel = (p.get("channel") or "").upper() # VOICE or CHAT
out = {"snFound": "false", "snTable": "", "snSysId": "", "snCreated": "false"}
user = None
try:
if email or phone:
q = "email=" + email if email else "phone=" + phone + "^ORmobile_phone=" + phone
users = sn_get("sys_user", q, "sys_id,name")
if users:
user = users[0]
out.update({"snFound": "true", "snCustomerName": user["name"],
"snTable": "sys_user", "snSysId": user["sys_id"]})
inc = sn_get("incident", "caller_id=" + user["sys_id"] +
"^active=true^ORDERBYDESCsys_updated_on", "sys_id,number")
if inc:
out.update({"snTable": "incident", "snSysId": inc[0]["sys_id"],
"snIncidentNumber": inc[0]["number"]})
return out
if AUTO_CREATE:
body = {
"short_description": "Amazon Connect " + (channel.lower() or "contact"),
"description": "Created automatically from Amazon Connect. "
"Email: " + (email or "-") + " Phone: " + (phone or "-"),
"contact_type": "phone" if channel == "VOICE" else "chat",
"category": "inquiry"}
if user:
body["caller_id"] = user["sys_id"]
new = sn_post("incident", body)
out.update({"snTable": "incident", "snSysId": new["sys_id"],
"snIncidentNumber": new["number"], "snCreated": "true"})
except Exception as e:
print("ServiceNow lookup/create failed:", e) # contact still routes normally
return out
NOTE With no user match, the incident has no caller and the email/phone goes in the description. contact_type values phone and chat are baseline choices; confirm them and set category to a value your service desk uses. |
|---|
TIP Optionally add snIncidentNumber to the Step E5 Set attributes block, so agents see it in Connect contact details and a flow can tell the customer (e.g. "Your reference is INC0012345"). |
|---|
Step E8: Test incident creation
1. Chat as a known customer with no open incidents: a new incident should open with them as caller, contact type chat.
2. Call from a number not in ServiceNow: a caller-less incident opens with the number in the description.
3. Chat as a customer with an open incident: that incident opens; none is created.
4. End the first test chat; the Part F transcript should appear on the new incident within minutes.
Symptom | Likely cause | Fix |
|---|---|---|
HTTP 403 on create | User cannot create incidents | Add itil (step 1 above) |
Timeout, no incident | Three calls exceed the timeout | 7 s in Lambda and flow; check ServiceNow speed |
Duplicate incident | Lambda invoked twice (e.g. transfer/retry path) | Invoke once per contact |
Contact type blank | Choice value differs | Change contact_type in code |
8. Step F — Copy Chat Transcripts into ServiceNow (optional)
Chat transcripts live in Connect. Here, a second Lambda runs as each chat ends, reads the transcript Connect saved to S3, and adds it to the matching incident as a work note and text attachment.
Step | Where | What happens |
|---|---|---|
1 | Connect | Chat ends; transcript saved as JSON in S3 |
2 | Amazon S3 | New file triggers the Lambda |
3 | AWS Lambda | Reads transcript and snSysId/snTable (Part E) |
4 | ServiceNow | Work note and attachment added to the incident |
NOTE Builds on Part E (needs snSysId and snTable; reuses the secret). Chats with no incident are skipped; enable Step E7 so every chat has one. |
|---|
Step F1: Confirm where chat transcripts are saved
1. In AWS, open Connect > your instance alias.
2. Choose Data storage.
3. Under Chat transcripts, note the S3 bucket and prefix (e.g. connect/mycompany/ChatTranscripts); if disabled, Edit, enable and pick a bucket.
4. Files (<contactId>_<timestamp>.json) appear shortly after each chat ends.
Step F2: Give the ServiceNow integration user write access
1. Open svc_connect_lookup (Step E1), or create e.g. svc_connect_transcripts.
2. Ensure it can write work notes and incident attachments (itil usually; for CSM, the case role).
3. Save the user.
TIP Separate read (lookup) and write (transcript) users ease auditing; work notes show this user as author. |
|---|
Step F3: Create the transcript Lambda
1. In Lambda, click Create function.
2. Name connect-transcript-to-servicenow, Python 3.12; Create function.
3. Replace lambda_function.py with the code below; Deploy.
4. Environment variables: SN_SECRET_ARN (Step E2) and CONNECT_INSTANCE_ID (ID at the end of the instance ARN).
5. General configuration: Timeout 30 seconds.
6. Permissions: allow s3:GetObject on the transcript bucket, connect:GetContactAttributes on your instance, secretsmanager:GetSecretValue on your secret.
import os, json, base64, urllib.request, urllib.parse
import boto3
s3 = boto3.client("s3"); connect = boto3.client("connect")
sm = boto3.client("secretsmanager")
INSTANCE_ID = os.environ["CONNECT_INSTANCE_ID"]
c = json.loads(sm.get_secret_value(SecretId=os.environ["SN_SECRET_ARN"])["SecretString"])
AUTH = "Basic " + base64.b64encode((c["user"] + ":" + c["password"]).encode()).decode()
def sn(method, path, body, ctype="application/json"):
data = body if isinstance(body, bytes) else json.dumps(body).encode()
req = urllib.request.Request(c["instance"] + path, data=data, method=method,
headers={"Authorization": AUTH, "Content-Type": ctype, "Accept": "application/json"})
with urllib.request.urlopen(req, timeout=10) as r:
return r.status
def lambda_handler(event, context):
for rec in event["Records"]:
bucket = rec["s3"]["bucket"]["name"]
key = urllib.parse.unquote_plus(rec["s3"]["object"]["key"])
t = json.loads(s3.get_object(Bucket=bucket, Key=key)["Body"].read())
contact_id = t.get("InitialContactId") or t["ContactId"]
attrs = connect.get_contact_attributes(InstanceId=INSTANCE_ID,
InitialContactId=contact_id)["Attributes"]
table = attrs.get("snTable"); sys_id = attrs.get("snSysId")
if table != "incident" or not sys_id:
print("No incident for contact", contact_id); continue
lines = []
for m in t.get("Transcript", []):
if m.get("Type") == "MESSAGE":
who = m.get("DisplayName") or m.get("ParticipantRole")
lines.append(m["AbsoluteTime"][11:19] + " " + who + ": " + m.get("Content", ""))
text = "Amazon Connect chat " + contact_id + "\n\n" + "\n".join(lines)
# 1) Work note (first 4000 characters)
sn("PATCH", "/api/now/table/incident/" + sys_id, {"work_notes": text[:4000]})
# 2) Full transcript as an attachment
q = urllib.parse.urlencode({"table_name": "incident", "table_sys_id": sys_id,
"file_name": "chat_" + contact_id + ".txt"})
sn("POST", "/api/now/attachment/file?" + q, text.encode(), "text/plain")
print("Transcript added to incident", sys_id)
NOTE The work note holds a summary (up to 4,000 characters); the attachment has the full transcript. For CSM, change "incident" to your case table (e.g. sn_customerservice_case). |
|---|
Step F4: Trigger the function when a transcript is saved
1. In the Lambda, click + Add trigger > S3.
2. Select the Step F1 bucket.
3. Event type: All object create events.
4. Prefix: the Step F1 transcript prefix (e.g. connect/mycompany/ChatTranscripts/); Suffix: .json.
5. Tick the acknowledgement; click Add.
IMPORTANT Set the prefix carefully; without it, recordings or reports in the bucket also trigger the function. |
|---|
Step F5: Test transcript sync
1. Chat as a customer with an open incident (so Part E sets snSysId).
2. Exchange a few messages, then end the chat.
3. Within minutes, the incident should show a new work note and chat_<contactId>.txt attachment.
4. If not, check the function's latest CloudWatch log.
Symptom | Likely cause | Fix |
|---|---|---|
Never runs | Wrong S3 prefix or suffix | Compare Step F4 with F1 |
Log: No incident for contact | snSysId unset or a user record | Check Part E; enable Step E7 |
AccessDenied in logs | Role lacks a permission | Check Step F3 permissions |
HTTP 403 from ServiceNow | User cannot write to incident | Check Step F2 |
Transcript twice | S3 sent the event twice (rare) | Accept, or add a duplicate check |
TIP Voice creates no chat transcripts. With Contact Lens, call transcripts are under a separate S3 Analysis prefix; this pattern can be adapted. |
|---|
9. Testing & Troubleshooting
Test checklist
# | Test | Expected result |
|---|---|---|
1 | Open the Contact Center page | Connect loads; agent signs in |
2 | Set status Available | Panel shows Available |
3 | Call your Connect number | Rings in panel; two-way audio |
4 | Chat from the website widget | Chat appears; agent replies |
5 | Take a call and chat together | Handled per routing limits |
6 | Known-email customer chats | Pop opens record or list |
7 | Navigate tabs mid-contact | No reload; contact stays |
8 | Dev tools: my.connect.aws frames | Only one Connect session |
9 | Q in Connect (if enabled) | Recommendations shown |
Series: ServiceNow on AWS (9 articles)
- …
- 8Embedding Amazon Connect Voice + Chat into ServiceNow This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article