npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

amazon-connect-customer-profiles

v1.0.0

Published

Provides access to customerProfiles for connect customers.

Downloads

70

Readme

amazon-connect-customer-profiles

Description

The Amazon Connect CustomerProfiles JavaScript library (CustomerProfilesJS) gives you the power to build your own CustomerProfiles widget.

The library uses Connect authentication token to make API calls to CustomerProfiles service. The client supports all CustomerProfile apis enabled on connect instance.

The client supports the following apis

  • SearchProfiles
  • CreateProfile
  • UpdateProfile
  • AddProfileKey
  • ListProfileObjects
  • ListAccountIntegrations

For more details on the apis, check out CustomerProfiles available via the AWS CLI.

Getting started

Pre-requisite

  • AmazonConnectCustomerProfiles depends on CCP widget from AmazonConnectStreams
  • To utilize AmazonConnectCustomerProfiles, start by allow listing your existing web application in the AWS Connect console. To allow list a domain URL follow the app integration guide.
  • Access to CustomerProfile apis can be controlled using Connect security profiles.

Usage

Build your own with NPM

amazon-connect-customer-profiles is available from npmjs.com. If you'd like to download it here, you can use either of the files like dist/amazon-connect-customer-profiles*.

Run npm run release to generate new release files.

$ git clone https://github.com/aws-connect/amazon-connect-customer-profiles
$ cd amazon-connect-customer-profiles
$ npm install
$ npm run release

Find build artifacts in dist directory - This will generate a file called amazon-connect-customer-profiles.js and the minified version of the same amazon-connect-customer-profiles-min.js.

Install using NPM

Install using npm:

npm install amazon-connect-customer-profiles

Initialization

The order of initialization matters:

  • Embed connect-streams javascript library before embedding amazon-connect-customer-profiles.
  • Initialize Connect CCP before initializing CustomerProfilesClient
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="connect-streams-min.js"></script>
    <script type="text/javascript" src="amazon-connect-customer-profiles-min.js"></script>
  </head>
  <body>
    <div id="container-div" style="width: 400px; height: 800px;"></div>
    <script type="text/javascript">
      let instanceName = 'https://test.my.connect.aws';

      // Initialize streams API
      var containerDiv = document.getElementById("container-div");
      connect.core.initCCP(
        containerDiv,
       	...
      );

      // Initialize customerProfilesJS client
      client = new connect.CustomerProfilesClient(instanceName);

    </script>
  </body>
</html>

Requests

CustomerProfilesJS client supports the following api methods.

Initialize the client

client = connect.CustomerProfilesClient(instanceName, endpoint);

CreateProfile

CreateProfile - creates a standard profile.

client.createProfile({
	"DomainName": "<DOMAIN_NAME>",
	"FirstName": "<FIRST_NAME>"
});

UpdateProfile

UpdateProfile - Updates the properties of a profile. The ProfileId is required for updating a customer profile.

client.updateProfile({
	"ProfileId": "<PROFILE_ID>",
	"FirstName": "<FIRST_NAME>",
	"LastName": "<LAST_NAME>",
	"DomainName": "<DOMAIN_NAME>"
});

SearchProfile

SearchProfile - Searches for profiles within a domain.

client.searchProfiles({
	"DomainName": "<DOMAIN_NAME>",
	"KeyName": "_profileId",
	"Values": [ "<PROFILE_ID>" ]
});

AddProfileKey

AddProfileKey - Associates a new key value with a specific profile, such as a Contact Trace Record (CTR) ContactId.

client.addProfileKey({
	"DomainName": "<DOMAIN_NAME>",
	"ProfileId": "<PROFILE_ID>",
	"KeyName": "_phone",
	"Values": [ "<PHONE_NUMBER>" ]
});

ListProfileObjects

ListProfileObjects - Returns a list of objects associated with a profile of a given ProfileObjectType.

client.listProfileObjects({
	"DomainName": "<DOMAIN_NAME>",
	"ObjectTypeName": "CTR",
	"ProfileId": "<PROFILE_ID>",
	"MaxResults": 10
});

ListAccountIntegrations

ListAccountIntegrations - Lists all of the integrations associated to a specific URI in the AWS account.

client.listAccountIntegrations({
	"Uri": "<URI>"
});

Response

All api calls through the client returns a promise. The promise resolves/rejects to provide the results from the api call. 200 status api status code is resolved and all other status codes are rejected.

Client response contains the following fields

  • status: api call status code
  • statusText: api call status text
  • data: api response data
{
	"status": 200,
	"statusText": "OK",
	"data": {<api_response>}
}

Reading response

You can use Promise chaining to read results from client response.

client.createProfile({
	"DomainName": "<DOMAIN_NAME>",
	"FirstName": "<FIRST_NAME>"
}).then((res) => {
	console.log('Success response: ' + JSON.stringify(res));
}).catch((errorResp) => {
    console.log('Error response: ' + JSON.stringify(errorResp));
});

Troubleshooting

Error message: Failed to execute ‘postMessage’ on ‘DOMWindow’: The target origin provided

This indicates that the customer-profiles hidden widget used by the client is not loaded. Ensure user has successfully signed in to connect instance and reload the page.

Contributing

See CONTRIBUTING for more information.

License

CustomerProfilesJS is distributed under the Apache License, Version 2.0, see LICENSE for more information.