Skip to content

Commit e3327d3

Browse files
author
Spencer Lepine
authored
update examples to support rich messaging (#88)
1 parent d95ac29 commit e3327d3

20 files changed

+347
-214
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
44
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
55

6+
## [1.3.1] - 2023-2-23
7+
### Added
8+
- Custom Chat Widget - Include Rich Messaging suppport
9+
- cloudformationTemplates - Include Rich Messaging suppport
10+
- Amazon Connect Chat now allows your agents and customers to use rich text formatting when composing a message, enabling them to quickly add emphasis and structure to messages, improving comprehension. The available formatting options include bold, italics, hyperlinks, bulleted lists, and numbered lists. [Learn more](https://docs.aws.amazon.com/connect/latest/adminguide/enable-text-formatting-chat.html)
11+
612
## [1.3.0] - 2023-1-19
713
### Added
814
- cloudformationTemplates - startChatContactAPI - Introduce Persistent Chat

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ If your instance was created before the release of the chat feature, here's an o
5252
3. Your existing contacts flows will also work for chat! You just need to update them to specify how you want them to work.
5353
We've added the following action blocks:
5454

55-
- [Wait](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#wait)
56-
- [Set disconnect flow](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#set-disconnect-flow)
55+
- [Wait](https://docs.aws.amazon.com/connect/latest/adminguide/wait.html)
56+
- [Set disconnect flow](https://docs.aws.amazon.com/connect/latest/adminguide/set-disconnect-flow.html)
5757

5858
And updated these blocks for chat:
5959

60-
- [Play prompt](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#play)
61-
- [Get customer input](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#get-customer-input)
62-
- [Store customer input](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#store-customer-input)
63-
- [Set recording behavior](https://docs.aws.amazon.com/connect/latest/adminguide/contact-blocks.html#set-recording-behavior)
60+
- [Play prompt](https://docs.aws.amazon.com/connect/latest/adminguide/play.html)
61+
- [Get customer input](https://docs.aws.amazon.com/connect/latest/adminguide/get-customer-input.html)
62+
- [Store customer input](https://docs.aws.amazon.com/connect/latest/adminguide/store-customer-input.html)
63+
- [Set recording behavior](https://docs.aws.amazon.com/connect/latest/adminguide/set-recording-behavior.html)
6464

6565
4. Your metric reports and the contact trace records will now reflect chat as a channel. Note the following metrics:
6666

cloudformationTemplates/asyncCustomerChatUX/README.md

+34
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,40 @@ If you want to enable sending attachments for Amazon Connect Chat the customer c
126126
},successHandler, failureHandler)
127127
```
128128

129+
## Enabling rich messaging
130+
131+
Amazon Connect Chat now allows your agents and customers to use rich text formatting when composing a message, enabling them to quickly add emphasis and structure to messages, improving comprehension. The available formatting options include bold, italics, hyperlinks, bulleted lists, and numbered lists. [Documentation](https://docs.aws.amazon.com/connect/latest/adminguide/enable-text-formatting-chat.html)
132+
133+
1. To enable rich messaging, include the new param when invoking `initiateChat`:
134+
135+
```js
136+
connect.ChatInterface.initiateChat({
137+
contactFlowId: "${contactFlowId}",
138+
instanceId: "${instanceId}",
139+
// ...
140+
supportedMessagingContentTypes: "text/plain,text/markdown", // include 'text/markdown' for rich messaging support
141+
featurePermissions: {
142+
ATTACHMENTS: false,
143+
MESSAGING_MARKDOWN: true
144+
}
145+
},successHandler, failureHandler)
146+
```
147+
148+
2. If updating an exisiting CFN stack, the startChatContact lambda function needs to be updated.
149+
150+
Be sure to pass `supportedMessagingContentTypes` input to `startChatContact()`:
151+
152+
```js
153+
function startChatContact(body) {
154+
return new Promise(function (resolve, reject) {
155+
var startChat = {
156+
// ...
157+
...(!!body["SupportedMessagingContentTypes"] && { "SupportedMessagingContentTypes": body["SupportedMessagingContentTypes"] })
158+
};
159+
})
160+
}
161+
```
162+
129163
## Enabling message receipts
130164

131165
Render and send read/delivered message receipts for customer chat-interface. Enable the feature [in the admin console](https://docs.aws.amazon.com/connect/latest/adminguide/message-receipts.html), and update [`chat-interface`](https://github.com/amazon-connect/amazon-connect-chat-interface#message-receipts) to generate latest webpack bundle.

cloudformationTemplates/asyncCustomerChatUX/js/startChatContact.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ exports.handler = (event, context, callback) => {
4949
console.log("start chat result "+ JSON.stringify(startChatResult));
5050

5151
var contactId = startChatResult.ContactId;
52-
53-
updatePreviousConnectionData(previousConnectionData.currentContactId, startChatResult.ContactId).then((updateStatus) => {
52+
updatePreviousConnectionData(previousConnectionData.currentContactId, contactId).then((updateStatus) => {
5453
console.log("update was successful? " + updateStatus);
5554

5655
putNewConnectionData(previousConnectionData.currentContactId, startChatResult, userId, displayName).then((status) => {
@@ -69,7 +68,7 @@ exports.handler = (event, context, callback) => {
6968
};
7069

7170
function startChatContact(contactFlowId, username, body, instanceId) {
72-
return new Promise(function (resolve, reject) {
71+
return new Promise(function (resolve, reject) {
7372
var startChat = {
7473
"InstanceId": instanceId == "" ? process.env.INSTANCE_ID : instanceId,
7574
"ContactFlowId": contactFlowId == "" ? process.env.CONTACT_FLOW_ID : contactFlowId,
@@ -79,7 +78,9 @@ function startChatContact(contactFlowId, username, body, instanceId) {
7978
},
8079
"ParticipantDetails": {
8180
"DisplayName": body["ParticipantDetails"]["DisplayName"]
82-
}
81+
},
82+
// Enable rich messaging: https://docs.aws.amazon.com/connect/latest/adminguide/enable-text-formatting-chat.html
83+
...(!!body["SupportedMessagingContentTypes"] && { "SupportedMessagingContentTypes": body["SupportedMessagingContentTypes"] })
8384
};
8485

8586
connect.startChatContact(startChat, function(err, data) {
@@ -92,7 +93,6 @@ function startChatContact(contactFlowId, username, body, instanceId) {
9293
resolve(data);
9394
}
9495
});
95-
9696
});
9797
}
9898

0 commit comments

Comments
 (0)