Skip to content

Commit

Permalink
Release 0.20.5
Browse files Browse the repository at this point in the history
Release 0.20.5
  • Loading branch information
atjohns authored Jan 19, 2024
2 parents 43b96a9 + 7a7cd31 commit 6f36ca3
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 61 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.20.3] - 2023-12-27
## [0.20.5] - 2024-1-19
- Update Lamdba functions using Node to version 18. This required upgrading the Lambda code to use the JS SDK v3 as well.
- Dependency upgrades to fix critical vulnerabilities.

## [0.20.4] - 2023-12-27
- Add support for file attachments. See new File Uploads README for full details.
- Clean-up & fix issues related to webpack 5 and `npm run` related errors for some build types.

Expand Down
12 changes: 6 additions & 6 deletions lex-web-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lex-web-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lex-web-ui",
"version": "0.20.4",
"version": "0.20.5",
"description": "Amazon Lex Web Interface",
"author": "AWS",
"license": "Amazon Software License",
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-lex-web-ui",
"version": "0.20.4",
"version": "0.20.5",
"description": "Sample Amazon Lex Web Interface",
"main": "dist/lex-web-ui.min.js",
"repository": {
Expand Down
64 changes: 29 additions & 35 deletions src/initiate-chat-lambda/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const AWS = require('aws-sdk');
AWS.config.update({ region: process.env.REGION });
const connect = new AWS.Connect();
const { ConnectClient, StartChatContactCommand } = require("@aws-sdk/client-connect");
const client = new ConnectClient({ region: process.env.REGION });
const parentOrigin = process.env.PARENT_ORIGIN;

exports.handler = (event, context, callback) => {
Expand All @@ -16,7 +15,7 @@ exports.handler = (event, context, callback) => {
});
};

function startChatContact(body) {
async function startChatContact(body) {
let contactFlowId = "";
if (body.hasOwnProperty('ContactFlowId')) {
contactFlowId = body["ContactFlowId"];
Expand Down Expand Up @@ -46,38 +45,33 @@ function startChatContact(body) {
attributes = body["Attributes"];
}

return new Promise(function(resolve, reject) {
const startChat = {
"InstanceId": instanceId == "" ? process.env.INSTANCE_ID : instanceId,
"ContactFlowId": contactFlowId == "" ? process.env.CONTACT_FLOW_ID : contactFlowId,
"Attributes": attributes,
"ChatDurationInMinutes": 60,
"ParticipantDetails": {
"DisplayName": body["ParticipantDetails"]["DisplayName"]
}
};

if (initialMsgContent && initialMsgContentType != "" ){
startChat.InitialMessage = {
"Content": initialMsgContent,
"ContentType": initialMsgContentType
};
const startChat = {
"InstanceId": instanceId == "" ? process.env.INSTANCE_ID : instanceId,
"ContactFlowId": contactFlowId == "" ? process.env.CONTACT_FLOW_ID : contactFlowId,
"Attributes": attributes,
"ChatDurationInMinutes": 60,
"ParticipantDetails": {
"DisplayName": body["ParticipantDetails"]["DisplayName"]
}
};

if (initialMsgContent && initialMsgContentType != "" ){
startChat.InitialMessage = {
"Content": initialMsgContent,
"ContentType": initialMsgContentType
};

console.log('startChat params', startChat);
connect.startChatContact(startChat, function(err, data) {
if (err) {
console.log("Error starting the chat.");
console.log(err, err.stack);
reject(err);
}
else {
console.log("Start chat succeeded with the response: " + JSON.stringify(data));
resolve(data);
}
});

});
};

console.log('startChat params', startChat);
const command = new StartChatContactCommand(startChat);
try {
const response = await client.send(command);
return response;
} catch (error) {
console.log("Error starting the chat.");
console.log(error, error.stack);
return response;
}
}

function buildSuccessfulResponse(result) {
Expand Down
18 changes: 10 additions & 8 deletions src/streaming-lambda/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10', region: process.env.AWS_REGION });
const { PutCommand, DynamoDBDocumentClient } = require('@aws-sdk/lib-dynamodb');
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');

const client = new DynamoDBClient({ apiVersion: '2012-08-10', region: process.env.AWS_REGION });
const docClient = DynamoDBDocumentClient.from(client);

exports.handler = async event => {
console.log("Received event: " + JSON.stringify(event));
const ttlTime = Date.now() / 1000 + 86400; //One day later in epoch time for TTL

const putParams = {
const command = new PutCommand({
TableName: process.env.TABLE_NAME,
Item: {
connectionId: event.requestContext.connectionId,
sessionId: event.queryStringParameters.sessionId,
ttl: ttlTime
}
};

});
try {
await ddb.put(putParams).promise();
await docClient.send(command);
return { statusCode: 200, body: 'Connected.' };
} catch (err) {
return { statusCode: 500, body: 'Failed to connect: ' + JSON.stringify(err) };
}

return { statusCode: 200, body: 'Connected.' };
};
2 changes: 1 addition & 1 deletion templates/cognito.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ Resources:
Condition: ShouldAllowSignUpEmailDomain
Properties:
Handler: index.handler
Runtime: nodejs14.x
Runtime: nodejs18.x
Timeout: 3
Environment:
Variables:
Expand Down
2 changes: 1 addition & 1 deletion templates/restapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Resources:
Description: AWS Lambda Function to initiate the chat with the end user
Handler: "index.handler"
Role: !GetAtt InitiateChatLambdaExecutionRole.Arn
Runtime: "nodejs14.x"
Runtime: "nodejs18.x"
MemorySize: 128
Timeout: 30
Environment:
Expand Down
2 changes: 1 addition & 1 deletion templates/streaming-support.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Resources:
Description: AWS Lambda Function to initiate web socket connection for streaming
Handler: "index.handler"
Role: !GetAtt StreamingLambdaExecutionRole.Arn
Runtime: "nodejs14.x"
Runtime: "nodejs18.x"
MemorySize: 128
Timeout: 30
Environment:
Expand Down

0 comments on commit 6f36ca3

Please sign in to comment.