You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 14, 2025. It is now read-only.
description: See how to use URL Interpolation and send Toast using the Client App SDK.
2
+
title: Using Client App SDK with Platform SDK
3
+
description: Learn how to use the Client App SDK with the Platform SDK
4
4
categories:
5
5
- Architect
6
6
- Notifications
7
7
steps:
8
8
- title: Introduction
9
9
content: |
10
-
This tutorial walks through the steps how to integrate with [Genesys Cloud Client App SDK](https://developer.mypurecloud.com/api/client-apps/). The Client App SDK framework lets developers embed custom web based applicaitons in the Genesys Cloud web.
10
+
This tutorial walks through the steps of integrating a web app with the [Genesys Cloud Client App SDK](/api/client-apps/) and the [Genesys Cloud Platform SDK](/api/rest/client-libraries/javascript/index.html).
11
+
12
+
The Client App SDK grants web applications access to unique functionalities when they're embedded as a Client App Integration or Interaction Widget.
11
13
12
-
The main topics that will be covered in the tutorial are the following:
14
+
The Javascript Platform SDK provides a way to consume the Genesys Cloud Platform API which is used in general purpose integrations with Genesys Cloud.
13
15
14
-
* Referencing the CDN library
15
-
* URL Interpolation to deterimine pcLangTag and pcEnvironment
16
-
* Sending toast message notifications
16
+
This tutorial shows how to set-up a simple integration using the two SDKs.
In this tutorial, the pcLangTag will be used to determine which language the app will use for displays. And the pcEnvironment will be used to determine which Client ID will be used for authentication.
43
-
44
-
- title: Deep Dive on pcLangTag
45
-
content: |
46
-
Before the app loads, it needs to determine which language to be used for the HTML fields.
47
-
48
-
This logic gets the locale of the current user. This value follows the bcp 74 pattern. Once the locale is determined, HTML fields will be populated accordingly.
49
-
50
-
- title: Deep Dive on pcLangTag
51
-
content: |
52
-
A separate JSON file is configured to store language translations per HTML field. If the locale does not have the language specified in the JSON file, it will default to en-us.
53
-
54
-
- title: Deep Dive on pcEnvironment for Authentication
55
-
content: |
56
-
Before we can start making Genesys Cloud API calls, we need to determine the Genesys Cloud environment that the app is running in.
57
-
58
-
```
59
-
ex. mypurecloud.com, mypurecloud.ie, mypurecloud.com.au, mypurecloud.jp, etc.
Different regions have different OAuth Client IDs so it must be determined before attempting to authenticate.
40
+
After acquiring both the environment and language values from the query parameters, they will be persisted using the localStorage. This is important because in the Implicit Grant Authentication step, the page will be redirected without the query parameters values.
63
41
64
-
Once the pcEnvironment is determined, we can pass the value to the JavaScript method for authentication.
42
+
Once the page reloads and there are no query parameters, then it will attempt to reassign both the environment and language variables with the values that are stored in the localStorage.
65
43
66
-
- title: Deep Dive on pcEnvironment for Authentication
44
+
- title: Setting up the Client SDK
67
45
content: |
68
-
We need to filter the object to get which Client ID to be used and call the loginImplicitGrant() method of the Javascript PureCloud SDK. If the pcEnvironment is not set, it will default to mypurecloud.com region.
46
+
A ClientApp instance needs to be created with the correct environment for its configuration.
69
47
70
-
Below is a sample of the clientIDs constant with different client IDs per region. For this sample, we are only using mypurecloud.com.
48
+
For more information on the Client App SDK, go to this [page](/api/client-apps/sdk/index.html/)
71
49
72
-
```{"language":"json"}
73
-
{
74
-
'mypurecloud.com': 'your-client-id',
75
-
'mypurecloud.ie': 'your-client-id',
76
-
'mypurecloud.com.au': 'your-client-id',
77
-
'mypurecloud.jp': 'your-client-id'
78
-
}
79
-
```
80
-
- title: Creating Toast Notifications for Incoming Calls
50
+
- title: Implicit Grant Authentication
81
51
content: |
82
-
Aside form URL Interpolation, the Client App SDK also has the capability to send toast messages.
52
+
In order to use the Genesys Cloud API, an implicit grant authentication needs to be accomplished. After authentication it should redirect to the URL in the redirectUri variable.
83
53
84
-
- title: Creating a Notification Channel and Subscribing to Conversations
85
-
content: |
86
-
In order to send toast notifications for incoming calls, we need to create a channel and subscribe to call conversations of the current user.
54
+
For more information on authorization see this [page](/api/rest/authorization/)
87
55
88
-
We need to use the JavaScript Genesys Cloud SDK and call the postNotificationsChannels() and the postNotificationsChannelSubscriptions() of the Notifications API.
89
-
90
-
- title: Handling Websocket Messages
56
+
- title: Toast Popup
91
57
content: |
92
-
For every websocket message the app receives, we need to determine if the Topic ID in the socket message matches the Topic ID we used in subscribing to the channel. Once the Topic ID has been validated, we can proceed in calling the method to send the toast message.
58
+
After setting up both the Client App SDK and the Platform SDK, they can now be used to their full advantages.
93
59
94
-
- title: Calling Toast Popup in the Client App SDK
95
-
content: |
96
-
To show a toast popup in Genesys Cloud, we need to call the showToastPopup() method of the Alerting API on the Client App SDK passing the title, message and options (optional) as parameters.
60
+
In this example, we use the Platform SDK to query the user details and then, using the Client App SDK, show a Toast up in order to greet them.
97
61
98
-
For more details on how to configure options in the Toast Popup, you may read more about [alerting.showToastPopup(title, message, options)](https://developer.mypurecloud.com/api/client-apps/client-app-sdk.html#module_alerting).
0 commit comments