├── website-creator ├── web-site-manifest.json ├── package.json ├── index.js ├── website-helper.js ├── css │ └── style.css ├── rpapis.html └── js │ └── rpapi.js ├── package.json ├── CODE_OF_CONDUCT.md ├── README.md ├── LICENSE ├── CONTRIBUTING.md └── template.yaml /website-creator/web-site-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "./rpapis.html", 4 | "./css/style.css", 5 | "./js/aws-sdk.min-rp.js", 6 | "./js/rpapi.js" 7 | ] 8 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ac-routingprofilesapi", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC" 11 | } 12 | -------------------------------------------------------------------------------- /website-creator/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "website-creator", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC" 11 | } 12 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ## Code of Conduct 2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 4 | opensource-codeofconduct@amazon.com with any additional questions or comments. 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Amazon Connect routing profile API's demo 3 | 4 | This demo shows how you can leverage [Amazon Connect](https://aws.amazon.com/connect/) api's to manage routing profiles. 5 | 6 | ## Usage 7 | Use `sam` to build, invoke and deploy the function. 8 | 9 | ##### SAM Build: 10 | Ensure you are in the root folder 11 | 12 | `sam build --use-container` 13 | 14 | ##### SAM Deploy: 15 | `sam deploy template.yaml --s3-bucket REPLACE_ME --stack-name REPLACE_ME --parameter-overrides ParameterKey=parS3BucketForWebSite,ParameterValue=REPLACE_ME --capabilities CAPABILITY_IAM` 16 | 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 10 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 11 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 13 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 14 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | 16 | -------------------------------------------------------------------------------- /website-creator/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | const https = require('https'); 3 | const url = require('url'); 4 | const WebsiteHelper = require('./website-helper.js'); 5 | 6 | exports.handler = (event, context, callback) => { 7 | console.log('Received event:', JSON.stringify(event, null, 2)); 8 | 9 | let responseStatus = 'FAILED'; 10 | let responseData = {}; 11 | 12 | if (event.RequestType === 'Delete') { 13 | sendResponse(event, callback, context.logStreamName, 'SUCCESS'); 14 | } 15 | 16 | if (event.RequestType === 'Create') { 17 | if (event.ResourceProperties.customAction === 'configureWebsite') { 18 | console.log('Starting to copy the files'); 19 | let _websiteHelper = new WebsiteHelper(); 20 | 21 | _websiteHelper.copyWebSiteAssets(event.ResourceProperties, 22 | function(err, data) { 23 | if (err) { 24 | responseData = { 25 | Error: 'Copy of website assets failed' 26 | }; 27 | console.log([responseData.Error, ':\n', err].join('')); 28 | } else { 29 | responseStatus = 'SUCCESS'; 30 | responseData = {}; 31 | } 32 | 33 | sendResponse(event, callback, context.logStreamName, responseStatus, responseData); 34 | }); 35 | 36 | } 37 | //sendResponse(event, callback, context.logStreamName, 'SUCCESS'); 38 | } 39 | 40 | 41 | }; 42 | 43 | /** 44 | * Sends a response to the pre-signed S3 URL 45 | */ 46 | 47 | let sendResponse = function(event, callback, logStreamName, responseStatus, responseData) { 48 | const responseBody = JSON.stringify({ 49 | Status: responseStatus, 50 | Reason: `See the details in CloudWatch Log Stream: ${logStreamName}`, 51 | PhysicalResourceId: logStreamName, 52 | StackId: event.StackId, 53 | RequestId: event.RequestId, 54 | LogicalResourceId: event.LogicalResourceId, 55 | Data: responseData, 56 | }); 57 | 58 | console.log('RESPONSE BODY:\n', responseBody); 59 | const parsedUrl = url.parse(event.ResponseURL); 60 | const options = { 61 | hostname: parsedUrl.hostname, 62 | port: 443, 63 | path: parsedUrl.path, 64 | method: 'PUT', 65 | headers: { 66 | 'Content-Type': '', 67 | 'Content-Length': responseBody.length, 68 | } 69 | }; 70 | 71 | const req = https.request(options, (res) => { 72 | console.log('STATUS:', res.statusCode); 73 | console.log('HEADERS:', JSON.stringify(res.headers)); 74 | callback(null, 'Successfully sent stack response!'); 75 | }); 76 | 77 | req.on('error', (err) => { 78 | console.log('sendResponse Error:\n', err); 79 | callback(err); 80 | }); 81 | 82 | req.write(responseBody); 83 | req.end(); 84 | }; -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional 4 | documentation, we greatly value feedback and contributions from our community. 5 | 6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary 7 | information to effectively respond to your bug report or contribution. 8 | 9 | 10 | ## Reporting Bugs/Feature Requests 11 | 12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features. 13 | 14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already 15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful: 16 | 17 | * A reproducible test case or series of steps 18 | * The version of our code being used 19 | * Any modifications you've made relevant to the bug 20 | * Anything unusual about your environment or deployment 21 | 22 | 23 | ## Contributing via Pull Requests 24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that: 25 | 26 | 1. You are working against the latest source on the *master* branch. 27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already. 28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted. 29 | 30 | To send us a pull request, please: 31 | 32 | 1. Fork the repository. 33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change. 34 | 3. Ensure local tests pass. 35 | 4. Commit to your fork using clear commit messages. 36 | 5. Send us a pull request, answering any default questions in the pull request interface. 37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation. 38 | 39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and 40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/). 41 | 42 | 43 | ## Finding contributions to work on 44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start. 45 | 46 | 47 | ## Code of Conduct 48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct). 49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact 50 | opensource-codeofconduct@amazon.com with any additional questions or comments. 51 | 52 | 53 | ## Security issue notifications 54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue. 55 | 56 | 57 | ## Licensing 58 | 59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution. 60 | 61 | We may ask you to sign a [Contributor License Agreement (CLA)](http://en.wikipedia.org/wiki/Contributor_License_Agreement) for larger changes. 62 | -------------------------------------------------------------------------------- /website-creator/website-helper.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | let AWS = require('aws-sdk'); 4 | let s3 = new AWS.S3(); 5 | const fs = require('fs'); 6 | const _downloadLocation = './web-site-manifest.json'; 7 | 8 | /** 9 | * Helper function to interact with s3 hosted website for cfn custom resource. 10 | * 11 | * @class websiteHelper 12 | */ 13 | let websiteHelper = (function() { 14 | 15 | /** 16 | * @class websiteHelper 17 | * @constructor 18 | */ 19 | let websiteHelper = function() {}; 20 | 21 | websiteHelper.prototype.copyWebSiteAssets = function(resourceProperties, cb) { 22 | var destS3Bucket = resourceProperties.destS3Bucket; 23 | var destS3KeyPrefix = resourceProperties.destS3KeyPrefix; 24 | var region = resourceProperties.Region; 25 | 26 | console.log("Copying UI web site"); 27 | console.log(['destination bucket:', destS3Bucket].join(' ')); 28 | console.log(['destination s3 key prefix:', destS3KeyPrefix].join(' ')); 29 | console.log(['region:', region].join(' ')); 30 | 31 | fs.readFile(_downloadLocation, 'utf8', function(err, data) { 32 | if (err) { 33 | console.log(err); 34 | return cb(err, null); 35 | } 36 | 37 | console.log(data); 38 | let _manifest = validateJSON(data); 39 | 40 | if (!_manifest) { 41 | return cb('Unable to validate downloaded manifest file JSON', null); 42 | } else { 43 | uploadToS3(_manifest.files, 0, destS3Bucket, destS3KeyPrefix, 44 | function(err, result) { 45 | if (err) { 46 | return cb(err, null); 47 | } 48 | console.log(result); 49 | return cb(null, result); 50 | }); 51 | } 52 | 53 | }); 54 | }; 55 | 56 | 57 | /** 58 | * Helper function to validate the JSON structure of contents of an import manifest file. 59 | * @param {string} body - JSON object stringify-ed. 60 | * @returns {JSON} - The JSON parsed string or null if string parsing failed 61 | */ 62 | let validateJSON = function(body) { 63 | try { 64 | let data = JSON.parse(body); 65 | console.log(data); 66 | return data; 67 | } catch (e) { 68 | // failed to parse 69 | console.log('Manifest file contains invalid JSON.'); 70 | return null; 71 | } 72 | }; 73 | 74 | async function uploadToS3(filelist, index, destS3Bucket, destS3KeyPrefix, cb) { 75 | if (filelist.length > index) { 76 | 77 | const response = fs.readFileSync(filelist[index], 'utf8'); 78 | var fileDetails = filelist[index] 79 | fileDetails = fileDetails.substring(2, fileDetails.length); 80 | 81 | let params2 = { 82 | Bucket: destS3Bucket, 83 | Key: destS3KeyPrefix + '/' + fileDetails, 84 | Body: response 85 | }; 86 | if (filelist[index].endsWith('.htm') || filelist[index].endsWith('.html')) { 87 | params2.ContentType = "text/html"; 88 | } else if (filelist[index].endsWith('.css')) { 89 | params2.ContentType = "text/css"; 90 | } else if (filelist[index].endsWith('.js')) { 91 | params2.ContentType = "application/javascript"; 92 | } else if (filelist[index].endsWith('.png')) { 93 | params2.ContentType = "image/png"; 94 | } else if (filelist[index].endsWith('.jpg') || filelist[index].endsWith('.jpeg')) { 95 | params2.ContentType = "image/jpeg"; 96 | } else if (filelist[index].endsWith('.pdf')) { 97 | params2.ContentType = "application/pdf"; 98 | } else if (filelist[index].endsWith('.gif')) { 99 | params2.ContentType = "image/gif"; 100 | } else if (filelist[index].endsWith('.svg')) { 101 | params2.ContentType = "image/svg+xml"; 102 | }; 103 | 104 | s3.putObject(params2, function(err, data) { 105 | if (err) { 106 | console.log(err); 107 | return cb(['error copying ', [filelist[index]].join('/'), '\n', err] 108 | .join( 109 | ''), 110 | null); 111 | } 112 | 113 | console.log([ 114 | [filelist[index]].join('/'), 'uploaded successfully' 115 | ].join(' ')); 116 | let _next = index + 1; 117 | uploadToS3(filelist, _next, destS3Bucket, destS3KeyPrefix, function(err, resp) { 118 | if (err) { 119 | return cb(err, null); 120 | } 121 | 122 | cb(null, resp); 123 | }); 124 | }); 125 | } else { 126 | cb(null, [index, 'files copied'].join(' ')); 127 | } 128 | } 129 | return websiteHelper; 130 | 131 | })(); 132 | 133 | module.exports = websiteHelper; -------------------------------------------------------------------------------- /template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Description: > 3 | Amazon Connect Routing Profiles APIs demo 4 | 5 | Mappings: 6 | FunctionMap: 7 | Configuration: 8 | S3Bucket: "amazon-connect-blogs2" 9 | S3Key: "2020/routingprofilesapi/" 10 | 11 | Parameters: 12 | parS3BucketForWebSite: 13 | Type: String 14 | AllowedPattern: '(?=^.{3,63}$)(?!^(\d+\.)+\d+$)(^(([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$)' 15 | ConstraintDescription: 'Invalid S3 Bucket name' 16 | Description: Enter the (globally unique) name you would like to use for the Amazon S3 bucket where we will store the website assets. This template will fail to deploy if the bucket name you chose is currently in use. 17 | 18 | Metadata: 19 | 'AWS::CloudFormation::Interface': 20 | ParameterGroups: 21 | - Label: 22 | default: Amazon S3 Configuration 23 | Parameters: 24 | - parS3BucketForWebSite 25 | 26 | ParameterLabels: 27 | parS3BucketForWebSite: 28 | default: Website Bucket Name 29 | 30 | Outputs: 31 | 32 | CloudfrontEndpoint: 33 | Description: Endpoint for Cloudfront distribution 34 | Value: !Join 35 | - '' 36 | - - 'https://' 37 | - !GetAtt [RPCloudFrontDistribution, DomainName] 38 | - '/rpapis.html' 39 | 40 | 41 | Resources: 42 | createWebSiteS3Bucket: 43 | Type: 'AWS::S3::Bucket' 44 | Properties: 45 | BucketName: !Ref parS3BucketForWebSite 46 | VersioningConfiguration: 47 | Status : Enabled 48 | BucketEncryption: 49 | ServerSideEncryptionConfiguration: 50 | - ServerSideEncryptionByDefault: 51 | SSEAlgorithm: AES256 52 | PublicAccessBlockConfiguration: 53 | BlockPublicAcls: True 54 | BlockPublicPolicy: True 55 | IgnorePublicAcls: True 56 | RestrictPublicBuckets: True 57 | WebsiteConfiguration: 58 | IndexDocument: rpapis.html 59 | ErrorDocument: error.html 60 | 61 | 62 | RPs3BucketPolicy: 63 | Type: AWS::S3::BucketPolicy 64 | DependsOn: 65 | - RPCloudFrontDistributionAccessIdentity 66 | Properties: 67 | Bucket: !Ref createWebSiteS3Bucket 68 | PolicyDocument: 69 | Statement: 70 | - 71 | Action: 72 | - "s3:GetObject" 73 | Effect: "Allow" 74 | Principal: 75 | CanonicalUser: 76 | Fn::GetAtt: [ RPCloudFrontDistributionAccessIdentity , S3CanonicalUserId ] 77 | Resource: 78 | !Sub ${createWebSiteS3Bucket.Arn}/CCP/* 79 | 80 | RPCloudFrontDistributionAccessIdentity: 81 | Type: AWS::CloudFront::CloudFrontOriginAccessIdentity 82 | Properties: 83 | CloudFrontOriginAccessIdentityConfig: 84 | Comment: 'CloudFront endpoint for routing profiles blog' 85 | 86 | RPCloudFrontDistribution: 87 | Type: AWS::CloudFront::Distribution 88 | Properties: 89 | DistributionConfig: 90 | Origins: 91 | - DomainName: 92 | !Join 93 | - '' 94 | - - !Ref parS3BucketForWebSite 95 | - .s3.amazonaws.com 96 | Id: !Ref parS3BucketForWebSite 97 | OriginPath: '/CCP' 98 | S3OriginConfig: 99 | OriginAccessIdentity: 100 | !Join 101 | - '' 102 | - - 'origin-access-identity/cloudfront/' 103 | - !Ref RPCloudFrontDistributionAccessIdentity 104 | Enabled: 'true' 105 | Logging: 106 | Bucket: !GetAtt createWebSiteS3Bucket.DomainName 107 | Prefix: 'logs/' 108 | IncludeCookies: 'true' 109 | Comment: CloudFront endpoint for routing profiles blog 110 | DefaultRootObject: rpapis.html 111 | DefaultCacheBehavior: 112 | AllowedMethods: 113 | - DELETE 114 | - GET 115 | - HEAD 116 | - OPTIONS 117 | - PATCH 118 | - POST 119 | - PUT 120 | TargetOriginId: !Ref parS3BucketForWebSite 121 | ForwardedValues: 122 | QueryString: true 123 | Cookies: 124 | Forward: all 125 | ViewerProtocolPolicy: redirect-to-https 126 | Restrictions: 127 | GeoRestriction: 128 | RestrictionType: whitelist 129 | Locations: 130 | - US 131 | 132 | RPWebSiteContentLambdaRole: 133 | Type: "AWS::IAM::Role" 134 | Properties: 135 | AssumeRolePolicyDocument: 136 | Version: "2012-10-17" 137 | Statement: 138 | - 139 | Effect: "Allow" 140 | Principal: 141 | Service: 142 | - "lambda.amazonaws.com" 143 | Action: 144 | - "sts:AssumeRole" 145 | Path: "/" 146 | Policies: 147 | - 148 | PolicyName: !Sub ${AWS::StackName}-website-creator-policy 149 | PolicyDocument: 150 | Version: "2012-10-17" 151 | Statement: 152 | - 153 | Effect: "Allow" 154 | Action: 155 | - 'logs:CreateLogGroup' 156 | - 'logs:CreateLogStream' 157 | - 'logs:PutLogEvents' 158 | Resource: 159 | - !Sub "arn:${AWS::Partition}:logs:${AWS::Region}:${AWS::AccountId}:log-group:/aws/lambda/*" 160 | - 161 | Effect: "Allow" 162 | Action: 163 | - "s3:PutObject" 164 | - "s3:GetObject" 165 | - "s3:PutObjectAcl" 166 | Resource: 167 | - !Join 168 | - '' 169 | - - 'arn:' 170 | - !Ref 'AWS::Partition' 171 | - ':s3:::' 172 | - !Ref parS3BucketForWebSite 173 | - '/*' 174 | - 175 | Effect: "Allow" 176 | Action: 177 | - "s3:PutBucketPublicAccessBlock" 178 | Resource: 179 | - !Join 180 | - '' 181 | - - 'arn:' 182 | - !Ref 'AWS::Partition' 183 | - ':s3:::' 184 | - !Ref parS3BucketForWebSite 185 | - 186 | Effect: "Allow" 187 | Action: 188 | - "s3:GetObject" 189 | Resource: 190 | - !Join 191 | - '' 192 | - - 'arn:' 193 | - !Ref 'AWS::Partition' 194 | - ':s3:::' 195 | - 'amazon-connect-blogs2' 196 | - '/*' 197 | 198 | webSiteCreator: 199 | Type: "AWS::Lambda::Function" 200 | Properties: 201 | Description: > 202 | AWS Lambda Function that will create the website and upload it to the S3 bucket 203 | Handler: "index.handler" 204 | Role: !GetAtt RPWebSiteContentLambdaRole.Arn 205 | Runtime: "nodejs12.x" 206 | MemorySize: 256 207 | Timeout: 120 208 | Code: ./website-creator/ 209 | 210 | invokeWebSiteCreator: 211 | Type: Custom::CreateWebSite 212 | DependsOn: createWebSiteS3Bucket 213 | Properties: 214 | ServiceToken: !GetAtt webSiteCreator.Arn 215 | customAction: configureWebsite 216 | Region: !Ref AWS::Region 217 | destS3Bucket: !Ref parS3BucketForWebSite 218 | destS3KeyPrefix: CCP 219 | -------------------------------------------------------------------------------- /website-creator/css/style.css: -------------------------------------------------------------------------------- 1 | html, 2 | body { 3 | border: 0; 4 | margin: 0; 5 | padding: 0; 6 | } 7 | 8 | body { 9 | font: 100% "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 10 | min-width: 100%; 11 | min-height: 101%; 12 | color: #666; 13 | background: #eee; 14 | } 15 | 16 | p, 17 | label, 18 | legend { 19 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 20 | } 21 | 22 | h1 { 23 | margin: 10px 0 10px; 24 | font-size: 20px; 25 | color: #333333; 26 | } 27 | 28 | hr { 29 | color: inherit; 30 | height: 0; 31 | margin: 6px 0 6px 0; 32 | padding: 0; 33 | border: 1px solid #d9d9d9; 34 | border-style: none none solid; 35 | } 36 | 37 | section { 38 | display: block; 39 | width: 800px; 40 | margin: 10px auto; 41 | padding: 35px; 42 | border: 1px solid #cbcbcb; 43 | background-color: #FFF; 44 | -webkit-border-radius: 5px; 45 | -moz-border-radius: 5px; 46 | border-radius: 5px; 47 | box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 48 | -webkit-box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 49 | -moz-box-shadow: 0 2px 5px rgba(50, 50, 50, 0.1); 50 | } 51 | 52 | 53 | /* Special CSS for Call Controls Section */ 54 | 55 | fieldset.salesOrder { 56 | padding: 7px; 57 | } 58 | 59 | fieldset.callControls { 60 | padding: 3px; 61 | margin: 4px; 62 | -webkit-transition: margin-left 1s ease-in-out; 63 | z-index: 1; 64 | } 65 | 66 | .callControls { 67 | margin: 2px 2px; 68 | display: inline-block; 69 | border: 1px solid #bfbfbf; 70 | border-radius: 5px 5px 5px 5px; 71 | -webkit-border-radius: 5px 5px 5px 5px; 72 | -moz-border-radius: 5px 5px 5px 5px; 73 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 74 | width: auto; 75 | height: auto; 76 | font-size: 16px; 77 | box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 78 | -moz-box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 79 | -webkit-box-shadow: inset 0 1px 0 0 #fff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2, 0 2px 4px 0 #f2f2f2; 80 | text-shadow: 0 1px 0 #fff; 81 | background-image: linear-gradient(to top, #f2f2f2, #f2f2f2); 82 | background-color: #f2f2f2; 83 | } 84 | 85 | .callControls:hover, 86 | .callControls:active { 87 | border: 1px solid #8c8c8c; 88 | color: #8c8c8c; 89 | box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 90 | -moz-box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 91 | -webkit-box-shadow: inset 0 1px 0 0 #ffffff, inset 0 -1px 0 0 #d9d9d9, inset 0 0 0 1px #f2f2f2; 92 | background-color: #f2f2f2; 93 | } 94 | 95 | 96 | /* Form style */ 97 | 98 | mark.validate { 99 | display: inline-block; 100 | margin: 12px 0 0 10px; 101 | width: 16px; 102 | height: 16px; 103 | background: transparent none; 104 | } 105 | 106 | mark.valid { 107 | background: url(images/success.gif) no-repeat top left; 108 | } 109 | 110 | mark.error { 111 | background: url(images/error.gif) no-repeat top left; 112 | } 113 | 114 | form label, 115 | section label { 116 | display: inline-block; 117 | float: left; 118 | height: 1em; 119 | line-height: 1em; 120 | padding: 6px 0 0; 121 | width: 135px; 122 | font-size: 1em; 123 | margin: 5px 0; 124 | clear: both; 125 | } 126 | 127 | form label small, 128 | section label small { 129 | font-size: 0.75em; 130 | color: #ccc; 131 | } 132 | 133 | form label.verify { 134 | padding: 0; 135 | margin: 2px 10px 2px 0; 136 | width: 145px; 137 | text-align: right; 138 | } 139 | 140 | form label.verify img { 141 | padding: 1px; 142 | border: 1px solid #cccccc; 143 | -webkit-border-radius: 3px; 144 | -moz-border-radius: 3px; 145 | border-radius: 3px; 146 | } 147 | 148 | form button { 149 | width: 120px; 150 | padding: 4px; 151 | color: #666; 152 | background: #f5f5f5; 153 | border: 1px solid #ccc; 154 | margin: 5px 0; 155 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 156 | -webkit-border-radius: 5px; 157 | -moz-border-radius: 5px; 158 | border-radius: 5px; 159 | vertical-align: top; 160 | transition: all 0.25s ease-in-out; 161 | -webkit-transition: all 0.25s ease-in-out; 162 | -moz-transition: all 0.25s ease-in-out; 163 | box-shadow: 0 0 5px rgba(81, 203, 238, 0); 164 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 165 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 166 | } 167 | 168 | form input, 169 | form textarea, 170 | form select, 171 | section select, 172 | section input, 173 | section textarea { 174 | width: 220px; 175 | padding: 5px; 176 | color: #666; 177 | background: #f5f5f5; 178 | border: 1px solid #ccc; 179 | margin: 5px 0; 180 | font: 1em "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif; 181 | -webkit-border-radius: 5px; 182 | -moz-border-radius: 5px; 183 | border-radius: 5px; 184 | vertical-align: top; 185 | transition: all 0.25s ease-in-out; 186 | -webkit-transition: all 0.25s ease-in-out; 187 | -moz-transition: all 0.25s ease-in-out; 188 | box-shadow: 0 0 5px rgba(81, 203, 238, 0); 189 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 190 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 0); 191 | } 192 | 193 | form select { 194 | width: 232px; 195 | margin: 8px 0; 196 | } 197 | 198 | form input#verify { 199 | width: 55px; 200 | } 201 | 202 | form textarea, 203 | section textarea { 204 | width: 414px; 205 | } 206 | 207 | form input:focus, 208 | form textarea:focus, 209 | form select:focus, 210 | form button:focus, 211 | section input:focus, 212 | section textarea:focus, 213 | section select:focus { 214 | border: 1px solid #ddd; 215 | background-color: #fff; 216 | color: #333; 217 | outline: none; 218 | position: relative; 219 | z-index: 5; 220 | box-shadow: 0 0 5px rgba(81, 203, 238, 1); 221 | -webkit-box-shadow: 0 0 5px rgba(81, 203, 238, 1); 222 | -moz-box-shadow: 0 0 5px rgba(81, 203, 238, 1); 223 | -webkit-transform: scale(1.05); 224 | -moz-transform: scale(1.05); 225 | transition: all 0.25s ease-in-out; 226 | -webkit-transition: all 0.25s ease-in-out; 227 | -moz-transition: all 0.25s ease-in-out; 228 | } 229 | 230 | form input.error, 231 | form textarea.error, 232 | form select.error { 233 | box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 234 | -webkit-box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 235 | -moz-box-shadow: 0 0 5px rgba(204, 0, 0, 0.5); 236 | border: 1px solid #faabab; 237 | background: #fef3f3 238 | } 239 | 240 | form input.submit { 241 | width: auto; 242 | cursor: pointer; 243 | position: relative; 244 | border: 1px solid #282828; 245 | color: #fff; 246 | padding: 6px 16px; 247 | text-decoration: none; 248 | font-size: 1.1em; 249 | background: #555; 250 | background: -webkit-gradient( linear, left bottom, left top, color-stop(0.12, rgb(60, 60, 60)), color-stop(1, rgb(85, 85, 85))); 251 | background: -moz-linear-gradient( center bottom, rgb(60, 60, 60) 12%, rgb(85, 85, 85) 100%); 252 | box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25); 253 | -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 254 | -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 255 | text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25); 256 | } 257 | 258 | form input.submit:hover { 259 | background: #282828 !important; 260 | transition: none; 261 | -webkit-transition: none; 262 | -moz-transition: none; 263 | } 264 | 265 | form input.submit:active, 266 | form input.submit:focus { 267 | top: 1px; 268 | } 269 | 270 | form button.delete-comment { 271 | width: auto; 272 | cursor: pointer; 273 | position: relative; 274 | border: 1px solid #282828; 275 | color: #fff; 276 | border-radius: 5px; 277 | padding: 6px 16px; 278 | text-decoration: none; 279 | font-size: 1.1em; 280 | background: #555; 281 | background: -webkit-gradient( linear, left bottom, left top, color-stop(0.12, rgb(60, 60, 60)), color-stop(1, rgb(85, 85, 85))); 282 | background: -moz-linear-gradient( center bottom, rgb(60, 60, 60) 12%, rgb(85, 85, 85) 100%); 283 | box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25); 284 | -moz-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 285 | -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); 286 | text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25); 287 | } 288 | 289 | .copy { 290 | width: 30px; 291 | height: 29px; 292 | padding: 5px; 293 | color: #666; 294 | background: #f5f5f5; 295 | border: 1px solid #ccc; 296 | margin: 5px 0; 297 | } 298 | 299 | form button.delete-comment:hover { 300 | background: #282828 !important; 301 | transition: none; 302 | -webkit-transition: none; 303 | -moz-transition: none; 304 | } 305 | 306 | form button.delete-comment:active, 307 | form button.delet-comment:focus { 308 | top: 1px; 309 | } 310 | 311 | form button:hover { 312 | background: #eeeeee; 313 | transition: none; 314 | -webkit-transition: none; 315 | -moz-transition: none; 316 | } 317 | 318 | form input[type="submit"][disabled] { 319 | background: #888; 320 | } 321 | 322 | form fieldset { 323 | padding: 7px; 324 | border: 1px solid #eee; 325 | -webkit-border-radius: 5px; 326 | -moz-border-radius: 5px; 327 | margin: 0 0 20px; 328 | } 329 | 330 | form legend { 331 | padding: 7px 10px; 332 | font-weight: bold; 333 | color: #000; 334 | border: 1px solid #eee; 335 | -webkit-border-radius: 5px; 336 | -moz-border-radius: 5px; 337 | margin-bottom: 0 !important; 338 | margin-bottom: 20px; 339 | } 340 | 341 | form span.required { 342 | font-size: 13px; 343 | color: #ff0000; 344 | } 345 | 346 | section span.required { 347 | font-size: 13px; 348 | color: #ff0000; 349 | } 350 | 351 | fieldset { 352 | padding: 20px; 353 | border: 1px solid #eee; 354 | -webkit-border-radius: 5px; 355 | -moz-border-radius: 5px; 356 | margin: 0 0 20px; 357 | } 358 | 359 | legend { 360 | padding: 7px 10px; 361 | font-weight: bold; 362 | color: #000; 363 | border: 1px solid #eee; 364 | -webkit-border-radius: 5px; 365 | -moz-border-radius: 5px; 366 | margin-bottom: 0 !important; 367 | margin-bottom: 20px; 368 | } 369 | 370 | #message { 371 | margin: 1em 0; 372 | padding: 0; 373 | display: block; 374 | background: transparent none; 375 | } 376 | 377 | acronym { 378 | border-bottom: 1px dotted #ccc; 379 | } -------------------------------------------------------------------------------- /website-creator/rpapis.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Amazon Connect - Instance API's 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
118 |
119 |
120 | Amazon Connect Routing Profile APIs 121 |
122 | 123 | 124 | 125 | 126 | 127 |
128 |
129 |
130 |
131 |
132 | Selected routing profile details 133 | 134 |
135 |
136 |
137 |
138 | 139 |
140 | JSON Output 141 |
142 |
143 | 144 |
145 | Waiting for server to respond 146 |
147 |
148 | 149 |
150 | 151 |
152 |
153 | 157 |
158 |
159 |
160 | Routing profile details 161 |
162 | 163 | 164 | 165 | 168 | 171 | 172 | 173 | 176 | 179 | 180 | 181 | 184 | 187 | 188 | 189 | 192 | 195 | 196 | 197 | 200 | 203 | 204 | 205 | 208 | 211 | 212 | 213 | 214 |
166 | 167 | 169 | 170 |
174 | 175 | 177 | 178 |
182 | 183 | 185 | 186 |
190 | 191 | 193 | 194 |
198 | 199 | 201 | 202 |
206 | 207 | 209 | 210 |
215 | 216 | 217 | 218 | 219 |
220 |
221 |
222 |
223 |
224 |
225 |

Routing profile queues

226 | 227 | Add Queue 228 | Remove Queue 229 | 230 |
231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 |
NameChannelsPriorityDelay-
244 |
245 | 246 |
247 |
248 | 249 | 250 | 251 |
252 |
253 |
254 | Queue details 255 |
256 | 257 | 258 | 259 | 262 | 265 | 266 | 267 | 270 | 274 | 275 | 276 | 279 | 282 | 283 | 284 | 287 | 290 | 291 | 292 | 293 |
260 | 261 | 263 | 264 |
268 | 269 | 271 | Voice 272 | Chat 273 |
277 | 278 | 280 | 281 |
285 | 286 | 288 | 289 |
294 |
295 |
296 |
297 | 298 |
299 | 300 | 301 | 302 |
303 |
304 |
305 | Enter AWS credentials for routing profile management 306 |
307 | 308 | 309 | 310 | 313 | 316 | 319 | 322 | 323 | 324 | 327 | 330 | 331 | 332 | 333 | 336 | 339 | 340 | 341 | 342 |
311 | 312 | 314 | 315 | 317 | 318 | 320 | 321 |
325 | 326 | 328 | 329 |
334 | 335 | 337 | 338 |
343 |
344 |
345 | 346 |
347 |
348 |
349 |

Are you sure you want to delete the instance?

350 |
351 | 352 | 353 | -------------------------------------------------------------------------------- /website-creator/js/rpapi.js: -------------------------------------------------------------------------------- 1 | 2 | var credentials; 3 | var secretKey; 4 | var accessKey; 5 | var sessionId; 6 | var connect; 7 | var rpListTable; 8 | var rpList; 9 | var selectedRP; 10 | var selectedRPId; 11 | var queueList; 12 | var timerID; 13 | var dlgSourceAccessKey, dlgSourceSecretKey, dlgSourceRegion, dlgInstanceId; 14 | const GCREATE = 'CREATE'; 15 | const GMODIFY = 'MODIFY'; 16 | const GVOICE = 'VOICE'; 17 | const GCHAT = 'CHAT'; 18 | const GSTANDARD = 'STANDARD'; 19 | 20 | // allowed will be CREATE and MODIFY 21 | var currentOperation = GCREATE; 22 | 23 | $( document ).ready(function() { 24 | if (!checkCookie()) { 25 | setAWSConfig(dlgSourceAccessKey, dlgSourceSecretKey, dlgSourceRegion); 26 | setupAll(); 27 | } else { 28 | setupAll(); 29 | $( "#configDialog" ).dialog( "open" ); 30 | } 31 | }); 32 | 33 | function setupAll() { 34 | loadConnectAPIs(); 35 | $( "#createTabs" ).tabs(); 36 | 37 | $("#modifyRP").click(() => { 38 | currentOperation=GMODIFY; 39 | clear_form_elements('#rpAddQueue'); 40 | clear_form_elements('#rpDetailsNew'); 41 | $("#tblRPQueueList tbody").empty(); 42 | $("#btnCreateRP").hide(); 43 | $("#btnModifyRP").show(); 44 | $("#btnModifyRPConcurrency").show(); 45 | $("#btnModifyRPDefaultOBQ").show(); 46 | $( "#manageRPdialog" ).dialog( "open" ); 47 | populateRPDetails(selectedRPId); 48 | }); 49 | 50 | $("#btnModifyRP").click(() => { 51 | modifyRoutingProfileNameDesc(selectedRPId); 52 | }); 53 | 54 | $("#btnModifyRPConcurrency").click(() => { 55 | modifyRoutingProfileConcurrency(selectedRPId); 56 | }); 57 | 58 | $("#btnModifyRPDefaultOBQ").click(() => { 59 | modifyRoutingProfileDefaultQueue(selectedRPId); 60 | }); 61 | 62 | $("#listRP").click(() => { 63 | getListRoutingProfiles(); 64 | }); 65 | 66 | $("#createRP").click(() => { 67 | currentOperation=GCREATE; 68 | clear_form_elements('#rpAddQueue'); 69 | clear_form_elements('#rpDetailsNew'); 70 | $("#tblRPQueueList tbody").empty(); 71 | populateQueueList("#outBoundQueueList"); 72 | $("#btnCreateRP").show(); 73 | $("#btnModifyRP").hide(); 74 | $("#btnModifyRPConcurrency").hide(); 75 | $("#btnModifyRPDefaultOBQ").hide(); 76 | $( "#manageRPdialog" ).dialog( "open" ); 77 | }); 78 | 79 | $("#describeRP").click(() => { 80 | describeRP(selectedRPId); 81 | }); 82 | 83 | $("#deleteRP").click(() => { 84 | $( "#confirmDialog" ).dialog( "open" ); 85 | }); 86 | $("#btnCreateRP").click(() => { 87 | createRP(); 88 | $( "#manageRPdialog" ).dialog( "close" ); 89 | }); 90 | $("#btnPrefill").click(() => { 91 | fillInstanceDetails(); 92 | }); 93 | 94 | $("#awsConfiguration").click(() => { 95 | $( "#configDialog" ).dialog( "open" ); 96 | }); 97 | 98 | $("#btnConfiguration").click(() => { 99 | if (saveCookie()) { 100 | $( "#configDialog" ).dialog( "close" ); 101 | } else { 102 | $( "#configDialog" ).dialog( "open" ); 103 | } 104 | }); 105 | 106 | $("#dialog").dialog({ 107 | autoOpen: false, 108 | modal: true 109 | }); 110 | 111 | $("#manageRPdialog").dialog({ 112 | autoOpen: false, 113 | width: 1100, 114 | modal: true, 115 | resizable: false, 116 | height: "auto" 117 | 118 | }); 119 | 120 | $("#resultDialog").dialog({ 121 | autoOpen: false, 122 | modal: true 123 | }); 124 | 125 | 126 | $('#configDialog').dialog({ 127 | autoOpen: false, 128 | width: 850, 129 | modal: true, 130 | resizable: false, 131 | height: "auto" 132 | }); 133 | 134 | $('#addQueueDialog').dialog({ 135 | autoOpen: false, 136 | modal: true, 137 | resizable: false, 138 | width: "auto", 139 | height: "auto", 140 | buttons: { 141 | "Yes": function() { 142 | $( this ).dialog( "close" ); 143 | addRoutingProfile(selectedRPId); 144 | }, 145 | Cancel: function() { 146 | $( this ).dialog( "close" ); 147 | } 148 | } 149 | }); 150 | 151 | 152 | $( "#confirmDialog" ).dialog({ 153 | autoOpen: false, 154 | resizable: false, 155 | height: "auto", 156 | width: 400, 157 | modal: true, 158 | buttons: { 159 | "Yes": function() { 160 | $( this ).dialog( "close" ); 161 | deleteRoutingProfile(selectedRPId); 162 | }, 163 | Cancel: function() { 164 | $( this ).dialog( "close" ); 165 | } 166 | } 167 | }); 168 | 169 | rpListTable = $('#rpListTable').DataTable({ 170 | columnDefs: [ 171 | { 172 | targets: -1, 173 | className: 'dt-body-right' 174 | } 175 | ], 176 | columns: [{title: "Name"},{title: "Description"},{title: "# of queues associated"}, {title: "Outbound queue"}], 177 | select: true, 178 | paging: false, 179 | info: false, 180 | searching: false 181 | }); 182 | 183 | rpListTable.on( 'select', function ( e, dt, type, indexes ) { 184 | if ( type === 'row' ) { 185 | selectedRP = rpListTable.rows( indexes ).data()[0][0]; 186 | $('#selectedRP').val(selectedRP); 187 | for (var i=0; i< rpList.RoutingProfileSummaryList.length; i++) { 188 | if (selectedRP === rpList.RoutingProfileSummaryList[i].Name) { 189 | selectedRPId = rpList.RoutingProfileSummaryList[i].Id; 190 | break; 191 | } 192 | } 193 | } 194 | }); 195 | getListRoutingProfiles(); 196 | 197 | } 198 | 199 | async function createRP() { 200 | try { 201 | handleWindow(true, ''); 202 | // name, description, defaultOutboundQueueId, queues, mediaConcurrencies 203 | var queues = []; 204 | var mediaConcurrencies = []; 205 | 206 | if($('#chatChannel').is(":checked")) { 207 | if(parseInt($('#chatsPerAgent').val()) > 0) { 208 | var media = { 209 | "Channel": GCHAT, 210 | "Concurrency": $('#chatsPerAgent').val() 211 | }; 212 | mediaConcurrencies.push(media); 213 | } 214 | } 215 | 216 | if ($('#voiceChannel').is(":checked")) { 217 | var media = { 218 | "Channel": GVOICE, 219 | "Concurrency": "1" 220 | }; 221 | mediaConcurrencies.push(media); 222 | } 223 | 224 | $('#tblRPQueueList > tbody > tr').each(function(index, tr) { 225 | var q = {}; 226 | q['QueueReference'] = {}; 227 | $(this).find('input').each (function(index2) { 228 | var attributeName = $(this).attr('name'); 229 | console.log(attributeName, $(this).val()); 230 | 231 | switch(attributeName) { 232 | case('chkVoice'): 233 | if($(this).is(":checked")) { 234 | q['QueueReference']['Channel'] = (GVOICE); 235 | } 236 | break; 237 | case('chkChat'): 238 | if($(this).is(":checked")) { 239 | q['QueueReference']['Channel'] = (GCHAT); 240 | } 241 | break; 242 | case('priority'): 243 | q['Priority'] = $(this).val(); 244 | break; 245 | case('delay'): 246 | q['Delay'] = $(this).val(); 247 | break; 248 | default: 249 | break; 250 | } 251 | }); 252 | 253 | $(this).find('select').each (function(index2) { 254 | console.log($(this).attr('name'), $(this).val()); 255 | if($(this).attr('name') === 'rpQueue') { 256 | q['QueueReference']['QueueId'] = $(this).val(); 257 | } 258 | }); 259 | queues.push(q); 260 | }); 261 | 262 | let resp = await createRoutingProfile(dlgInstanceId, $('#rpNameNew').val(), $('#rpDescription').val(), $('#outBoundQueueList').val(), 263 | queues, mediaConcurrencies); 264 | console.log(resp); 265 | getListRoutingProfiles(); 266 | handleWindow(false, ''); 267 | } catch(e) { 268 | console.log(e); 269 | handleWindow(false, ''); 270 | showResults(e); 271 | } 272 | } 273 | 274 | async function modifyRoutingProfileNameDesc(profileId) { 275 | try { 276 | handleWindow(true, ''); 277 | let resp = await updateRoutingProfileName(dlgInstanceId, profileId, $('#rpNameNew').val(), $('#rpDescription').val()); 278 | console.log(resp); 279 | handleWindow(false, ''); 280 | } catch(e) { 281 | console.log(e); 282 | handleWindow(false, ''); 283 | showResults(e); 284 | } 285 | } 286 | 287 | async function modifyRoutingProfileDefaultQueue(profileId) { 288 | try { 289 | handleWindow(true, ''); 290 | let resp = await updateRoutingProfileDefaultOutboundQueue(dlgInstanceId, profileId, $('#outBoundQueueList').val()); 291 | console.log(resp); 292 | handleWindow(false, ''); 293 | } catch(e) { 294 | console.log(e); 295 | handleWindow(false, ''); 296 | showResults(e); 297 | } 298 | } 299 | 300 | 301 | async function modifyRoutingProfileConcurrency(profileId) { 302 | try { 303 | handleWindow(true, ''); 304 | var mediaConcurrencies = []; 305 | 306 | if($('#chatChannel').is(":checked")) { 307 | if(parseInt($('#chatsPerAgent').val()) > 0) { 308 | var media = { 309 | "Channel": GCHAT, 310 | "Concurrency": $('#chatsPerAgent').val() 311 | } 312 | mediaConcurrencies.push(media); 313 | } 314 | } 315 | 316 | if($('#voiceChannel').is(":checked")) { 317 | var media = { 318 | "Channel": GVOICE, 319 | "Concurrency": "1" 320 | } 321 | mediaConcurrencies.push(media); 322 | } 323 | 324 | let resp = await updateRoutingProfileConcurrency(dlgInstanceId, profileId, mediaConcurrencies); 325 | console.log(resp); 326 | handleWindow(false, ''); 327 | } catch(e) { 328 | console.log(e); 329 | handleWindow(false, ''); 330 | showResults(e); 331 | } 332 | } 333 | 334 | function populateQueueList(ele, selected) { 335 | var ddl = $(ele); 336 | ddl.html(''); 337 | for (var i=0; i < queueList.QueueSummaryList.length; i++) { 338 | if (queueList.QueueSummaryList[i].QueueType === 'STANDARD') { 339 | if (selected) { 340 | if (selected === queueList.QueueSummaryList[i].Id) { 341 | ddl.append(""); 342 | } else { 343 | ddl.append(""); 344 | } 345 | } else { 346 | ddl.append(""); 347 | } 348 | } 349 | 350 | } 351 | } 352 | 353 | async function populateRPDetails(profileId) { 354 | try{ 355 | let rp = await describeRoutingProfile(dlgInstanceId, profileId); 356 | console.log(rp); 357 | $('#rpNameNew').val(rp.RoutingProfile.Name); 358 | $('#rpDescription').val(rp.RoutingProfile.Description) 359 | for (var j=0; j 0) { 364 | $('#chatChannel').prop('checked', true); 365 | $('#chatsPerAgent').val(med.Concurrency); 366 | } else { 367 | $('#chatChannel').prop('checked', false); 368 | $('#chatsPerAgent').val(med.Concurrency); 369 | } 370 | } else { 371 | if(med.Concurrency > 0) { 372 | $('#voiceChannel').prop('checked', true); 373 | } else { 374 | $('#voiceChannel').prop('checked', false); 375 | } 376 | } 377 | } 378 | } 379 | populateQueueList('#outBoundQueueList', rp.RoutingProfile.DefaultOutboundQueueId); 380 | 381 | let rpq = await listRoutingProfileQueues(dlgInstanceId, profileId); 382 | console.log(rpq); 383 | var queueId=""; 384 | $("#tblRPQueueList tbody").empty(); 385 | var tbody = $('#tblRPQueueList').children('tbody'); 386 | var table = tbody.length ? tbody : $('#tblRPQueueList'); 387 | 388 | for(var j=0; j " + queueList.QueueSummaryList[i].Name + ""; 398 | } else { 399 | td += ""; 400 | } 401 | } 402 | } 403 | td += ''; 404 | if(item.Channel === GVOICE) { 405 | td += ' Voice '; 406 | } else { 407 | td += ' Chat '; 408 | } 409 | td += ''; 410 | td += ''; 411 | var a = ''; 412 | a += 'Save' +'' 413 | td += a; 414 | 415 | td += ''; 416 | table.append(td); 417 | } 418 | } catch(e) { 419 | console.log(e); 420 | showResults(e); 421 | } 422 | 423 | } 424 | 425 | 426 | async function addRoutingProfile() { 427 | try { 428 | var queueId = $('#addQueueList').val(); 429 | var queues = []; 430 | var channels = []; 431 | var q = {}; 432 | if($('#chkRPVoice').is(":checked")) { 433 | q['QueueReference'] = {}; 434 | q['QueueReference']['QueueId'] = queueId; 435 | q['QueueReference']['Channel'] = GVOICE; 436 | q['Priority'] =$('#rpPriority').val(); 437 | q['Delay'] =$('#rpDelay').val(); 438 | queues.push(q); 439 | } 440 | q = {}; 441 | if($('#chkRPChat').is(":checked")) { 442 | q['QueueReference'] = {}; 443 | q['QueueReference']['QueueId'] = queueId; 444 | q['QueueReference']['Channel'] = GCHAT; 445 | q['Priority'] =$('#rpPriority').val(); 446 | q['Delay'] =$('#rpDelay').val(); 447 | queues.push(q); 448 | } 449 | 450 | if (currentOperation === GMODIFY) { 451 | await associateRoutingProfileQueues(dlgInstanceId, selectedRPId, queues); 452 | } 453 | 454 | var tbody = $('#tblRPQueueList').children('tbody'); 455 | var table = tbody.length ? tbody : $('#tblRPQueueList'); 456 | var td=''; 457 | if ($('#chkRPVoice').is(":checked")) { 458 | td = getNewRowDetails(queueId, GVOICE); 459 | table.append(td); 460 | } 461 | 462 | if ($('#chkRPChat').is(":checked")) { 463 | td = getNewRowDetails(queueId, GCHAT); 464 | table.append(td); 465 | } 466 | } catch(e) { 467 | console.log(e); 468 | showResults(e); 469 | } 470 | 471 | } 472 | 473 | function getNewRowDetails(queueId, channel) { 474 | var td = ""; 475 | td += "'; 487 | 488 | if (channel === GVOICE) { 489 | td += ' Voice'; 490 | } 491 | 492 | if (channel === GCHAT) { 493 | td += ' Chat'; 494 | } 495 | 496 | td += ''; 497 | td += ''; 498 | if(currentOperation === GMODIFY) { 499 | var a = ''; 500 | a += 'Save' +'' 501 | td += a; 502 | } else { 503 | td += '-' 504 | } 505 | 506 | td += ''; 507 | return td; 508 | } 509 | 510 | function updatePriorityDelay(queueId, channel) { 511 | console.log(queueId); 512 | handleWindow(true, ''); 513 | $('#tblRPQueueList > tbody > tr').each(function(index, tr) { 514 | var rowQueueId =''; 515 | var priority = ''; 516 | var delay = ''; 517 | var foundMatch = false; 518 | $(this).find('select').each (function(index2) { 519 | rowQueueId = $(this).val(); 520 | }); 521 | if(rowQueueId === queueId){ 522 | $(this).find('input').each (function(index2) { 523 | if($(this).attr('name') === 'chkChat') { 524 | if(channel === GCHAT) 525 | foundMatch = true; 526 | } 527 | if($(this).attr('name') === 'chkVoice') { 528 | if(channel === GVOICE) 529 | foundMatch = true; 530 | } 531 | 532 | if($(this).attr('name')==='priority') { 533 | priority = $(this).val(); 534 | } 535 | if($(this).attr('name')==='delay') { 536 | delay = $(this).val(); 537 | } 538 | }); 539 | if(rowQueueId === queueId && foundMatch) { 540 | var q = {}; 541 | var queues =[]; 542 | q['QueueReference'] = {}; 543 | q['QueueReference']['QueueId'] = queueId; 544 | q['QueueReference']['Channel'] = channel; 545 | q['Priority'] = priority; 546 | q['Delay'] = delay; 547 | queues.push(q); 548 | updateRPDP(queues); 549 | } 550 | } 551 | }); 552 | handleWindow(false, ''); 553 | 554 | } 555 | 556 | async function updateRPDP(queues) { 557 | try{ 558 | await updateRoutingProfileQueues(dlgInstanceId, selectedRPId, queues); 559 | } catch (e) { 560 | console.log(e) 561 | showResults(e); 562 | handleWindow(false, ''); 563 | } 564 | 565 | } 566 | 567 | function addQueue() { 568 | populateQueueList('#addQueueList'); 569 | $( "#addQueueDialog" ).dialog( "open" ); 570 | } 571 | 572 | async function removeQueue() { 573 | if (currentOperation === GCREATE) { 574 | if ($("#selectAllQueues").is(":checked")) { 575 | $("#tblRPQueueList tbody").empty(); 576 | } else { 577 | // Check all the list boxes that are selected, remove the selected 578 | // queue/channel 579 | $('#tblRPQueueList > tbody > tr').each(function(index, tr) { 580 | var deleteMe = false; 581 | // if the checkbox is selected in the 1 column of row, then we 582 | // have to remove queue/channel from the routing profile 583 | // association 584 | $(this).find('input').each (function(index2) { 585 | if(index2 === 0) { 586 | console.log($(this).attr('name'), $(this).val()); 587 | if($(this).is(":checked")) 588 | deleteMe = true; 589 | } 590 | }); 591 | if (deleteMe) { 592 | $(this).remove(); 593 | } 594 | }); 595 | } 596 | } else { 597 | var queues = []; 598 | 599 | if ($("#selectAllQueues").is(":checked")) { 600 | $("#tblRPQueueList tbody").empty(); 601 | } else { 602 | $('#tblRPQueueList > tbody > tr').each(function(index, tr) { 603 | var deleteMe = false; 604 | var chkChat = false; 605 | var chkVoice = false; 606 | var queueId = ""; 607 | $(this).find('select').each (function(index2) { 608 | queueId = $(this).val(); 609 | }); 610 | $(this).find('input').each (function(index2) { 611 | if($(this).attr('name')==='selectQueue') { 612 | if($(this).is(":checked")) 613 | deleteMe = true; 614 | } 615 | if(deleteMe) { 616 | if($(this).attr('name')==='chkVoice') { 617 | if($(this).is(":checked")) { 618 | chkVoice = true; 619 | q = {} 620 | q['QueueId'] = queueId; 621 | q['Channel'] = 'VOICE'; 622 | queues.push(q); 623 | } 624 | 625 | } 626 | if($(this).attr('name')==='chkChat') { 627 | if($(this).prop("checked") === true) { 628 | chkChat = true; 629 | q = {} 630 | q['QueueId'] = queueId; 631 | q['Channel'] = 'CHAT'; 632 | queues.push(q); 633 | } 634 | 635 | } 636 | } 637 | 638 | }); 639 | if(deleteMe) 640 | $(this).remove(); 641 | }); 642 | } 643 | try { 644 | await disassociateRoutingProfileQueues(dlgInstanceId, selectedRPId, queues); 645 | } catch(e) { 646 | console.log(e); 647 | showResults(e); 648 | } 649 | } 650 | } 651 | 652 | async function getListRoutingProfiles() { 653 | try { 654 | handleWindow(true, ''); 655 | queueList = await listQueues(dlgInstanceId); 656 | console.log(queueList); 657 | rpList = await listRoutingProfiles(dlgInstanceId); 658 | console.log(rpList); 659 | formatJSON(rpList, '#rpFormatted'); 660 | rpListTable.clear(); 661 | for (var i=0; i< rpList.RoutingProfileSummaryList.length; i++) { 662 | var value = rpList.RoutingProfileSummaryList[i]; 663 | let rp = await describeRoutingProfile(dlgInstanceId, value.Id); 664 | console.log(rp); 665 | let rpq = await listRoutingProfileQueues(dlgInstanceId, value.Id); 666 | console.log(rpq); 667 | if (rp && rpq) { 668 | rpListTable.row.add([value.Name, rp.RoutingProfile.Description, rpq.RoutingProfileQueueConfigSummaryList.length, getQueueName(rp.RoutingProfile.DefaultOutboundQueueId)]); 669 | } 670 | } 671 | rpListTable.draw(); 672 | handleWindow(false, ''); 673 | } catch(e) { 674 | console.log(e); 675 | handleWindow(false, ''); 676 | showResults(e); 677 | } 678 | 679 | } 680 | 681 | function getQueueName(queueId) { 682 | for(var i=0; i < queueList.QueueSummaryList.length; i++) { 683 | if(queueId === queueList.QueueSummaryList[i].Id) { 684 | return queueList.QueueSummaryList[i].Name; 685 | } 686 | } 687 | } 688 | 689 | async function describeRP() { 690 | try { 691 | let rpq = await getDescribeRoutingProfile(selectedRPId); 692 | formatJSON(rpq, '#rpFormatted'); 693 | } catch(e) { 694 | 695 | } 696 | 697 | } 698 | 699 | const createRoutingProfile = (instanceId, name, description, defaultOutboundQueueId, queueConfigs, mediaConcurrencies) => { 700 | return new Promise((resolve,reject) => { 701 | var params = {InstanceId : instanceId, Name : name, Description : description, DefaultOutboundQueueId : defaultOutboundQueueId, 702 | QueueConfigs : queueConfigs, MediaConcurrencies : mediaConcurrencies}; 703 | console.log(params); 704 | connect.createRoutingProfile(params, function (err, res) { 705 | if (err) 706 | reject(err); 707 | else 708 | resolve(res); 709 | }); 710 | }); 711 | } 712 | 713 | const updateRoutingProfileName = (instanceId, routingProfileId, name, description) => { 714 | return new Promise((resolve,reject) => { 715 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, Name : name, Description : description}; 716 | console.log(params); 717 | connect.updateRoutingProfileName(params, function (err, res) { 718 | if (err) 719 | reject(err); 720 | else 721 | resolve(res); 722 | }); 723 | }); 724 | } 725 | 726 | const updateRoutingProfileConcurrency = (instanceId, routingProfileId, mediaConcurrencies) => { 727 | return new Promise((resolve,reject) => { 728 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, MediaConcurrencies : mediaConcurrencies}; 729 | console.log(params); 730 | connect.updateRoutingProfileConcurrency(params, function (err, res) { 731 | if (err) 732 | reject(err); 733 | else 734 | resolve(res); 735 | }); 736 | }); 737 | } 738 | 739 | 740 | const updateRoutingProfileDefaultOutboundQueue = (instanceId, routingProfileId, defaultOutboundQueueId) => { 741 | return new Promise((resolve,reject) => { 742 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, DefaultOutboundQueueId : defaultOutboundQueueId }; 743 | console.log(params); 744 | connect.updateRoutingProfileDefaultOutboundQueue(params, function (err, res) { 745 | if (err) 746 | reject(err); 747 | else 748 | resolve(res); 749 | }); 750 | }); 751 | } 752 | 753 | 754 | const associateRoutingProfileQueues = (instanceId, routingProfileId, queueConfigs) => { 755 | return new Promise((resolve,reject) => { 756 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, QueueConfigs : queueConfigs}; 757 | console.log(params); 758 | connect.associateRoutingProfileQueues(params, function (err, res) { 759 | if (err) 760 | reject(err); 761 | else 762 | resolve(res); 763 | }); 764 | }); 765 | } 766 | 767 | const updateRoutingProfileQueues = (instanceId, routingProfileId, queueConfigs) => { 768 | return new Promise((resolve,reject) => { 769 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, QueueConfigs : queueConfigs}; 770 | console.log(params); 771 | connect.updateRoutingProfileQueues(params, function (err, res) { 772 | if (err) 773 | reject(err); 774 | else 775 | resolve(res); 776 | }); 777 | }); 778 | } 779 | 780 | const disassociateRoutingProfileQueues = (instanceId, routingProfileId, queueReferences) => { 781 | return new Promise((resolve,reject) => { 782 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId, QueueReferences : queueReferences}; 783 | console.log(params); 784 | connect.disassociateRoutingProfileQueues(params, function (err, res) { 785 | if (err) 786 | reject(err); 787 | else 788 | resolve(res); 789 | }); 790 | }); 791 | } 792 | 793 | const listRoutingProfiles = (instanceId) => { 794 | return new Promise((resolve,reject) => { 795 | var params = {InstanceId : instanceId}; 796 | console.log(params); 797 | connect.listRoutingProfiles(params, function (err, res) { 798 | if (err) 799 | reject(err); 800 | else 801 | resolve(res); 802 | }); 803 | }); 804 | } 805 | 806 | async function getDescribeRoutingProfile(routingProfileId) { 807 | try { 808 | let resp = await describeRoutingProfile(dlgInstanceId, routingProfileId); 809 | console.log(resp); 810 | return resp; 811 | } catch(e) { 812 | console.log(e); 813 | } 814 | 815 | } 816 | 817 | const describeRoutingProfile = (instanceId, routingProfileId) => { 818 | return new Promise((resolve,reject) => { 819 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId}; 820 | console.log(params); 821 | connect.describeRoutingProfile(params, function (err, res) { 822 | if (err) 823 | reject(err); 824 | else 825 | resolve(res); 826 | }); 827 | }); 828 | } 829 | 830 | const listRoutingProfileQueues = (instanceId, routingProfileId) => { 831 | return new Promise((resolve,reject) => { 832 | var params = {InstanceId : instanceId, RoutingProfileId : routingProfileId}; 833 | console.log(params); 834 | connect.listRoutingProfileQueues(params, function (err, res) { 835 | if (err) 836 | reject(err); 837 | else 838 | resolve(res); 839 | }); 840 | }); 841 | } 842 | 843 | const listQueues = (instanceId) => { 844 | return new Promise((resolve,reject) => { 845 | var params = {InstanceId : instanceId}; 846 | console.log(params); 847 | connect.listQueues(params, function (err, res) { 848 | if (err) 849 | reject(err); 850 | else 851 | resolve(res); 852 | }); 853 | }); 854 | } 855 | 856 | function showResults(message){ 857 | $('#resultSpan').text(message); 858 | $("#resultDialog").dialog("open"); 859 | } 860 | 861 | function loadConnectAPIs() { 862 | connect = new AWS.Connect({ region: dlgSourceRegion}); 863 | } 864 | 865 | 866 | function handleWindow(openClose, text) { 867 | if(openClose == true) { 868 | $( "#dialog" ).dialog( "open" ); 869 | } else { 870 | $( "#dialog" ).dialog( "close" ); 871 | } 872 | 873 | if(text.length>1) { 874 | $('#waitingSpan').text(text); 875 | } else { 876 | $('#waitingSpan').text(' Waiting for server to respond'); 877 | } 878 | } 879 | 880 | function setAWSConfig(accessKey, secretKey, rgn) { 881 | 882 | AWS.config.update({ 883 | accessKeyId: accessKey, secretAccessKey: secretKey, region: rgn 884 | }); 885 | AWS.config.credentials.get(function (err) { 886 | if (err) 887 | console.log(err); 888 | else { 889 | credentials = AWS.config.credentials; 890 | getSessionToken(); 891 | } 892 | }); 893 | 894 | } 895 | 896 | function formatJSON(data, element) { 897 | $(element).html(prettyPrintJson.toHtml(data)); 898 | } 899 | 900 | 901 | function getSessionToken() { 902 | var sts = new AWS.STS(); 903 | sts.getSessionToken(function (err, data) { 904 | if (err) console.log("Error getting credentials"); 905 | else { 906 | secretKey = data.Credentials.SecretAccessKey; 907 | accessKey = data.Credentials.AccessKeyId; 908 | sessionId = data.Credentials.SessionToken; 909 | } 910 | }); 911 | } 912 | 913 | function clear_form_elements(ele) { 914 | $(':input',ele) 915 | .not(':button, :submit, :reset') 916 | .val('') 917 | .prop('checked', false) 918 | .prop('selected', false); 919 | } 920 | 921 | function saveCookie() { 922 | dlgSourceAccessKey=$("#dlgSourceAccessKey").val(); 923 | dlgSourceSecretKey=$("#dlgSourceSecretKey").val(); 924 | dlgSourceRegion=$("#dlgSourceRegion").val(); 925 | dlgInstanceId = $("#dlgInstanceId").val(); 926 | if(!checkAllMandatoryFields()) { 927 | setCookie("dlgSourceAccessKey", dlgSourceAccessKey,100); 928 | setCookie("dlgSourceSecretKey", dlgSourceSecretKey,100 ); 929 | setCookie("dlgSourceRegion", dlgSourceRegion,100); 930 | setCookie("dlgInstanceId", dlgInstanceId,100); 931 | $('#spnAWSMessage').text(''); 932 | setAWSConfig(dlgSourceAccessKey, dlgSourceSecretKey, dlgSourceRegion); 933 | return true; 934 | }else{ 935 | $('#spnAWSMessage').text('All fields are mandatory and cannot be whitespaces or null'); 936 | return false; 937 | } 938 | } 939 | 940 | function getCookie(c_name) 941 | { 942 | var i,x,y,ARRcookies=document.cookie.split(";"); 943 | for (i=0;i