Amazon Connect Streams Library
npm install keiron-amazon-connect-streams
The Amazon Connect Streams API (Streams) gives you the power to integrate your existing web applications with Amazon Connect. Streams lets you embed the Contact Control Panel (CCP) and Customer Profiles app UI into your page. It also enables you to handle agent and contact state events directly through an object oriented event driven interface. You can use the built in interface or build your own from scratch: Streams gives you the choice.
This library must be used in conjunction with amazon-connect-chatjs or amazon-connect-taskjs in order to utilize Amazon Connect's Chat or Task functionality.
release/connect-streams*. Run npm run release to generate new release files. Full instructions for building locally with npm can be found below.
In version 1.x, we also support make for legacy builds. This option was removed in version 2.x.
isSilentMonitor, isBarge, isSilentMonitorEnabled, isBargeEnabled, isUnderSupervision, updateMonitorParticipantState, getMonitorCapabilities, getMonitorStatus, isForcedMute.initCCP will no longer append multiple embedded CCPs to the window, and only the first call to initCCP will succeed. Please note that the use-case of initializing multiple CCPs with initCCP has never been supported by Streams, and this change has been added to prevent unpredictable behavior arising from such cases.agent.onContactPending has been removed. Please use contact.onPending instead. connect.onError now triggers. Previously, this api did not work at all. Please be aware that, if you have application logic within this function, its behavior has changed. See its entry in documentation.md for more details.agent.setState() to switch agent status, you will need to update your code to use this feature:enqueueNextState: true to trigger the Next Status behavior. agent.setState(), please also ensure that your code is using contact.clear() and not contact.complete() when clearing After Contact Work off a contact.FailedConnectAgent, FailedConnectCustomer, and AfterCallWork. FailedConnectAgent -- Previously, we required the agent to click the "Clear Contact" button to clear this state. When the agent clicked the "Clear Contact" button, the previous behavior took the agent back to the Available state without fail. Now the FailedConnectAgent state will be "auto-cleared", much like FailedConnectCustomer always has been. FailedConnectAgent and FailedConnectCustomer -- We are now using the contact.clear() API to auto-clear these states. As a result, the agent will be returned to their previous visible agent state (e.g. Available). Previously, the agent had always been set to Available as a result of this "auto-clearing" behavior. Note that even custom CCPs will behave differently with this update for FailedConnectAgent and FailedConnectCustomer.AfterCallWork -- As part of the new contact.clear() behavior, clicking "Clear Contact" while in AfterCallWork will return the agent to their previous visible agent state (e.g. Available, etc.). Note that custom CCPs that implement their own After Call Work behavior will not be affected by this change.contact.complete() on a deprecation path. Therefore, you should start using contact.clear() in its place. If you want to emulate CCP's After Call Work behavior in your customer CCP, then make sure you use contact.clear() when clearing voice contacts. To allowlist your pages:
1. Login to your AWS Account, then navigate to the Amazon Connect console.
2. Click the instance name of the instance for which you would like to allowlist
pages to load the settings page for your instance.
3. Click the "Application integration" link on the left.
4. Click "+ Add Origin", then enter a domain URL, e.g.
"https
website is hosted on a non-standard port.
#### A few things to note:
* Allowlisted domains must be HTTPS.
* All of the pages that attempt to initialize the Streams library must be hosted
on domains that are allowlisted as per the above steps.
* All open tabs that contain an initialized Streams library or any other CCP
tabs opened will be synchronized. This means that state changes made in one
open window will be communicated to all open windows.
* Using multiple browsers at the same time for the same connect instance is not supported, and causes issues with the rtc communication.
npm install amazon-connect-streamsimport "amazon-connect-streams";connect variable available in the current context.amazon-connect-streams is compatible with TypeScript. You'll need to use version 3.0.1 or higher:
``ts
import "amazon-connect-streams";
connect.core.initCCP({ / ... / });
`
``
$ git clone https://github.com/aws/amazon-connect-streams
Once you download streams, change into the directory and build it:
``
$ cd amazon-connect-streams
$ make
This will generate a file called connect-streams-${VERSION}.js, this is the fullconnect-streams-${VERSION}.js
Connect Streams API which you will want to include in your page. You can serve with your web application.
$ git clone https://github.com/aws/amazon-connect-streams
$ cd amazon-connect-streams
$ npm install
$ npm run release
`Find build artifacts in release directory - This will generate a file called
connect-streams.js and the minified version of the same connect-streams-min.js - this is the full Connect Streams API which you will want to include in your page.To run unit tests:
`
$ npm run test-mocha
`
Note: these tests run on the release files generated above$3
You will also need to have gulp installed. You can install gulp globally.`
$ npm install -g gulp
$ git clone https://github.com/aws/amazon-connect-streams
$ cd amazon-connect-streams
$ npm install
$ npm run release
`Find build artifacts in release directory - This will generate a file called
connect-streams.js and the minified version of the same connect-streams-min.js - this is the full Connect Streams API which you will want to include in your page.To run unit tests:
`
$ npm run gulp-test
`
Note: these tests run on the release files generated aboveUsing the AWS SDK and Streams
Streams has a "baked-in" version of the AWS-SDK in the ./src/aws-client.js file. Make sure that you import Streams before the AWS SDK so that the AWS object bound to the Window is the object from your manually included SDK, and not from Streams.Initialization
Initializing the Streams API is the first step to verify that you have
everything setup correctly and that you will be able to listen for events.$3
`html
`
Integrates with Connect by loading the pre-built CCP located at ccpUrl into an
iframe and placing it into the containerDiv provided. API requests are
funneled through this CCP and agent and contact updates are published through it
and made available to your JS client code.
* ccpUrl: The URL of the CCP. This is the page you would normally navigate to
in order to use the CCP in a standalone page, it is different for each
instance.
* region: Amazon connect instance region. ex: us-west-2. only required for chat channel.
* loginPopup: Optional, defaults to true. Set to false to disable the login popup
which is shown when the user's authentication expires.
* loginOptions: Optional, only valid when loginPopup is set to true.
Provide an object with the following properties to open loginpopup in a new window instead of a
new tab.
* autoClose: Optional, defaults to false. Set to true to automatically
close the login popup after the user logs in.
* height: This allows you to define the height of the login pop-up window.
* width: This allows you to define the width of the login pop-up window.
* top: This allows you to define the top of the login pop-up window.
* left: This allows you to define the left of the login pop-up window.
* loginPopupAutoClose: Optional, defaults to false. Set to true in conjunction with the
loginPopup parameter to automatically close the login Popup window once the authentication step
has completed. If the login page opened in a new tab, this parameter will also auto-close that
tab. This can also be set in loginOptions if those options are used.
* loginUrl: Optional. Allows custom URL to be used to initiate the ccp, as in
the case of SAML authentication.
* softphone: This object is optional and allows you to specify some settings
surrounding the softphone feature of Connect.
* allowFramedSoftphone: Normally, the softphone microphone and speaker
components are not allowed to be hosted in an iframe. This is because the
softphone must be hosted in a single window or tab. The window hosting
the softphone session must not be closed during the course of a softphone
call or the call will be disconnected. If allowFramedSoftphone is true,
the softphone components will be allowed to be hosted in this window or tab.
* disableRingtone: This option allows you to completely disable the built-in
ringtone audio that is played when a call is incoming.
* ringtoneUrl: If the ringtone is not disabled, this allows for overriding
the ringtone with any browser-supported audio file accessible by the user. To use the default ringtone comment out this line.
* pageOptions: This object is optional and allows you to configure which configuration sections are displayed in the settings tab.
* enableAudioDeviceSettings: If true, the settings tab will display a section for configuring audio input and output devices for the agent's local
machine. If false, or if pageOptions is not provided, the agent will not be able to change audio device settings from the settings tab. will not be
displayed.
* enablePhoneTypeSettings: If true, or if pageOptions is not provided, the settings tab will display a section for configuring the agent's phone type
and deskphone number. If false, the agent will not be able to change the phone type or deskphone number from the settings tab.
* shouldAddNamespaceToLogs: prepends [CCP] to all logs logged by the CCP. Important note: there are a few logs made by the CCP before the namespace is prepended.
* ccpAckTimeout: A timeout in ms that indicates how long streams will wait for the iframed CCP to respond to its SYNCHRONIZE event emissions. These happen continuously from the first time initCCP is called. They should only appear when there is a problem that requires a refresh or a re-login.
* ccpSynTimeout: A timeout in ms that indicates how long streams will wait to send a new SYNCHRONIZE event to the iframed CCP. These happens continuously from the first time initCCP is called.
* ccpLoadTimeout: A timeout in ms that indicates how long streams will wait for the initial ACKNOWLEDGE event from the shared worker while the CCP is still standing itself up.
#### A few things to note:
* You have the option to show or hide the pre-built UI by showing or hiding the
containerDiv into which you place the iframe, or applying a CSS rule like
this:
`css
#container-div iframe {
display: none;
}
`
* The CCP UI is rendered in an iframe under the container element provided.
The iframe fills its container element with width: 100%; height: 100%`.