Remember: CPC is a client-side API. Actions are carried out in context of current logged on user. Returned values depend on user account's rights.
Terminology: CPC API and this document use the term "interaction" when referring to inbound or outbound conversations with customers. The term "conversation" is used in other Sinch Contact Pro applications.
Tip: Remember to
Have a great time integrating Communication Panel into your application! 😀
Terminology: CPC API and this document use the term "interaction" when referring to inbound or outbound conversations with customers. The term "conversation" is used in other Sinch Contact Pro applications.
Tip: Remember to
await
when using async
methods.Have a great time integrating Communication Panel into your application! 😀
- Source
Namespaces
Members
activeInteractionId :string|undefined|null
ID of current active interaction being viewed in Communication Panel.
Type:
- string |
undefined | null
- Source
currentUser :object
Holds details of current user. Value is set once CPC has initialized.
Note: In case user's details change during session and most recent data is needed, call getDetails like this instead:
Note: In case user's details change during session and most recent data is needed, call getDetails like this instead:
await CPC.getDetails('user')
.Type:
- object
- Source
hostAppEventHandler :function
Event handler that is called per each event sent by Communication Panel. Initially provided as parameter for CPC.load. Can be changed at any time.
Type:
- function
- Source
isInitialized :boolean
True when user is logged in and CPC is ready to interact with Communication Panel.
Type:
- boolean
- Source
Methods
(async) authenticate_basic(sUsername, sPassword) → {boolean}
Authenticate Contact Pro user with basic authentication.
Note: When using this authentication option, be sure to handle user credentials with care. In your application you must prevent credentials getting logged or otherwise getting stored persistently. When possible, use
Recommended: Authentication can also be handled as part of load call.
Note: When using this authentication option, be sure to handle user credentials with care. In your application you must prevent credentials getting logged or otherwise getting stored persistently. When possible, use
authenticate_token
instead.Recommended: Authentication can also be handled as part of load call.
Parameters:
Name | Type | Description |
---|---|---|
sUsername | string | Username |
sPassword | string | Password |
- Source
Returns:
Authentication result
- Type:
- boolean
(async) authenticate_token(authToken) → {boolean}
Authenticate Contact Pro user with OAuth.
Good article about the process https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info/
Contact Pro ECF Web Server assumes that the Issuer (token
ECF server calls
Upon successful token verification, the
ECF server finally identifies Contact Pro user based on
Recommended: Authentication can also be handled as part of load call.
Good article about the process https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info/
Contact Pro ECF Web Server assumes that the Issuer (token
iss
claim) implements OAuth {iss}/.well-known/openid-configuration
endpoint which returns user_info
URL.ECF server calls
user_info
URL to request verification for token.Upon successful token verification, the
user_info
endpoint must return 200 OK
and payload {sub: '', email: ''}
where values correspond with Contact Pro user's Certificate Subject and Email values.ECF server finally identifies Contact Pro user based on
sub
and email
, and grants session cookie, allowing browser to access resources behind ECF Web Server.Recommended: Authentication can also be handled as part of load call.
Parameters:
Name | Type | Description |
---|---|---|
authToken | string | OAuth token |
- Source
Returns:
Authentication result
- Type:
- boolean
(async) callOut(destinationNumber, sourceQueueNumberopt) → {object|false}
Sends a call out request to Communication Panel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
destinationNumber | string | Destination phone number. | |
sourceQueueNumber | string | <optional> | Queue number to be used as Visible A Number for the call. Note:User must have appropriate serve rights to the Queue. Tip:Check list of user's queues first with getCurrentUserQueues |
- Source
Returns:
Phone call object, or false if creating a call failed.
- Type:
- object |
false
(async) callState(action, interactionIdopt) → {false|Object}
Change state of ongoing phone call.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action | 'startRecording' | | State change to be performed on currently ongoing phone call. | |
interactionId | string | <optional> | Id of interaction that should be acted on. Defaults to user's current active interaction being viewed in Communication Panel. |
- Source
Returns:
Changed interaction object, or false if action failed.
- Type:
- false |
Object
(async) consult(to, interactionIdopt) → {object|false}
In context of ongoing interaction currently selected in Communication Panel (or in context of explicitly defined interaction), create a consultation interaction.
The original phone call is put on hold, and a new phone call is created. Later the calls can be joined by calling joinCalls. Possible for
The original phone call is put on hold, and a new phone call is created. Later the calls can be joined by calling joinCalls. Possible for
phone
and chat
type interactions.Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
to | string | Address or number of destination Queue or User. | |
interactionId | string | <optional> | Id of the ongoing interaction. |
- Source
Returns:
Created interaction object, or false if action failed.
- Type:
- object |
false
(async) dtmf(tone, interactionIdopt) → {false|Object}
Send DTMF tone to current active interaction being viewed in Communication Panel. This works only with
phone
channel.Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tone | '0' | | The tone to be sent. | |
interactionId | string | <optional> | Specify ongoing phone interaction for which tone is sent. |
- Source
Returns:
Corresponding interaction object, or false if action failed.
- Type:
- false |
Object
(async) getCurrentUserQueues(sChannelType) → {Array}
Get the currently logged on user's queue list.
Parameters:
Name | Type | Description |
---|---|---|
sChannelType | 'phone' | | Optionally filter by channel. |
- Source
Returns:
Array of queue(s).
- Type:
- Array
(async) getDetails(subject) → {object}
Returns details of defined subject.
Parameters:
Name | Type | Description |
---|---|---|
subject | 'user' | | Subject of details request. |
- Source
Returns:
Object including details of the given subject. In CPExtInterface schema, see "detail".
- Type:
- object
getTenantBaseUrl() → {string}
Get Contact Pro tenant/installation base URL. This is provided initially as parameter for load.
- Source
Returns:
URL.
- Type:
- string
hasOngoingInteraction(channelType) → {boolean}
Check if user has any ongoing interaction(s) in Communication Panel.
Parameters:
Name | Type | Description |
---|---|---|
channelType | 'phone' | | Optionally check specified channel type only. |
- Source
Returns:
True when there is at least one ongoing interaction.
- Type:
- boolean
hasOngoingInteractionOfType(channelType) → {boolean}
Check if user has ongoing interaction(s) of specific type.
Parameters:
Name | Type | Description |
---|---|---|
channelType | 'phone' | | Channel |
- Deprecated
- Source
Returns:
True when there is at least one ongoing interaction.
- Type:
- boolean
init() → {void}
Sends initialization request to Communication Panel. As result, Communication Panel will start sending events and accepting commands from CPC.
Note: This is needed only if load is not used to automatically inject Communication Panel.
Recommended: Use load instead. It internally handles calling
Note: This is needed only if load is not used to automatically inject Communication Panel.
Recommended: Use load instead. It internally handles calling
init
so you don't need to.- Source
Returns:
No return value.
- Type:
- void
(async) interaction(action, interactionIdopt) → {Object|false}
Perform a state changing action on the current active interaction being viewed in Communication Panel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
action | 'accept' | | Type of action to perform. | |
interactionId | string | <optional> | Specify ID of ongoing interaction which should be acted upon. |
- Source
Returns:
Changed interaction object, or false if action failed.
- Type:
- Object |
false
(async) joinCalls() → {object|false}
Joins currently active original inbound or outbound phone call interaction and corresponding consultation call.
This drops the agent/user from the ongoing calls, connects other parties in a joined phone call.
Note: After
This drops the agent/user from the ongoing calls, connects other parties in a joined phone call.
Note: After
joinCalls
completes, phone call signaling and voice still remain connected via Sinch Contact Pro backend but can no longer be controlled by CPC.- Source
Returns:
The interaction object of phone call from which the agent/user left, or false if action failed.
- Type:
- object |
false
(async) load(config) → {boolean}
Load Communication Panel into host application. Optionally provide authentication for automated user login.
Tip: It's easy to try this on the CPC Playground page. See link in top banner.
Tip: It's easy to try this on the CPC Playground page. See link in top banner.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config | Object | Object containing initial configuration for CPC.Properties
|
- Source
Returns:
Load result.
- Type:
- boolean
(async) message(message, interactionIdopt) → {false|Object}
Send a textual message to active
chat
interaction. Works also with sms chats.Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
message | string | Message content | |
interactionId | string | <optional> | Specific interaction for which the message should be sent. |
- Source
Returns:
Corresponding interaction object, or false if action failed.
- Type:
- false |
Object
ongoingInteractions() → {Map.<string, object>}
Returns a
Map
containing all currently ongoing interaction(s) cached by CPC. These interactions include the extra timestamps appended by CPC.- Source
Returns:
Key = InteractionId, Value = interaction
- Type:
- Map.<string, object>
(async) sendEmail(email) → {object|false}
Create a new email.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
email | Object | Object containing following propertiesProperties
|
- Source
Returns:
Created email interaction object, or false on failure.
- Type:
- object |
false
(async) sendSMS(msg) → {object|false}
Start a one-to-one SMS message based chat.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
msg | Object | Object containing following propertiesProperties
|
- Source
Returns:
Created SMS interaction object, or false if creation failed.
- Type:
- object |
false
(async) startWhatsAppChat(chat) → {object|false}
Start a new WhatsApp chat.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
chat | Object | Object containing following propertiesProperties
|
- Source
Returns:
Created WhatsApp chat interaction object, or false if creation failed.
- Type:
- object |
false
(async) transfer(to, interactionIdopt) → {object|false}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
to | string | Address or number of destination queue or user. | |
interactionId | string | <optional> | Id of the ongoing interaction. |
- Source
Returns:
Created WhatsApp interaction object, or false if creation failed.
- Type:
- object |
false
(async) unload() → {boolean}
Unload performs two steps:
1. Sends request to server to invalidate current authentication cookie -> Server logs out currently logged in user.
2. CPC deletes the
Note: This is a 'hard logout' which does not take into account possibly ongoing interaction(s) such as phone calls or chats. If needed, call
1. Sends request to server to invalidate current authentication cookie -> Server logs out currently logged in user.
2. CPC deletes the
iframe
element that contains Communication Panel.Note: This is a 'hard logout' which does not take into account possibly ongoing interaction(s) such as phone calls or chats. If needed, call
hasOngoingInteraction()
first. If user needs to log back in, call load
to re-inject Communication Panel.- Source
Returns:
Unload result.
- Type:
- boolean
(async) xdmSendAction(payload) → {object}
Helper for sending
Note: Usually there is no need to call this directly.
In CPC there is a convenience method per each capability/feature of the underlying CPExtInterface. Convenience methods handle calling
action
messages to Communication Panel.Note: Usually there is no need to call this directly.
In CPC there is a convenience method per each capability/feature of the underlying CPExtInterface. Convenience methods handle calling
xdmSendAction
internally, so you don't have to.Parameters:
Name | Type | Description |
---|---|---|
payload | object | Object containing documented attributes and values. |
- Source
Returns:
Response payload value from Communication Panel.
- Type:
- object