Use Guest Chat Client - JavaScript with ReactJS

Hi Forum,
we have two ReactJS projects, one is a web portal and the other one is an phone app made with React Native.

We tried to integrate the JavaScript guest chat code available in the library:
https://developer.mypurecloud.com/api/rest/client-libraries/javascript-guest/index.html
but we got some issues in both projects.

INSTALLATION WITH NPM
Installing the library through the repository
yarn add purecloud-guest-chat-client
and importing it into the project
const platformClient = require('purecloud-guest-chat-client')
platformClient is an empty object, so not usable.

IMPORTING DIRECTLY THE JS FILE
We can import the library but we are forced to share the file globally in whole project and use it with
<script type="text/javascript">
platformClient = require('platformClient');
</script>
const client = window.platformClient.ApiClient.instance
but is not a smooth solution and there are some security problems.

Is there a working version of the library that we can install using the repository?
If not, what other solutions we have for realize a stable and secure WebChat client (Standard JS SDK, REST API..) ?

Thank you in advance.

You need to configure webpack to consume the es6 sources, not the pre-transpiled CJS library. See the React example in this project, last thing in the readme: https://github.com/MyPureCloud/platform-client-sdk-javascript-beta. That project is using the platform api sdk, but it has the same shape as the guest chat sdk.

Of course, if you don't like the way the SDK works in your app, you can always fork it and modify it or make the API requests using whatever libraries you prefer: https://developer.mypurecloud.com/api/webchat/guestchat.html

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.