Chat Setup
How to setup Pylon's Chat Widget
Installation
Add Script to Body Add the following
<script>to right before the</body>tag in yourindex.html. Make sure to replace theAPP_IDwith theAPP_IDyou grabbed from Step 1.<script> (function(){var e=window;var t=document;var n=function(){n.e(arguments)};n.q=[];n.e=function(e){n.q.push(e)};e.Pylon=n;var r=function(){var e=t.createElement("script");e.setAttribute("type","text/javascript");e.setAttribute("async","true");e.setAttribute("src","https://widget.usepylon.com/widget/APP_ID");var n=t.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};if(t.readyState==="complete"){r()}else if(e.addEventListener){e.addEventListener("load",r,false)}})(); </script>If you are using EU data hosting, then use the following
<script>instead:<script> (function(){var e=window;var t=document;var n=function(){n.e(arguments)};n.q=[];n.e=function(e){n.q.push(e)};e.Pylon=n;var r=function(){var e=t.createElement("script");e.setAttribute("type","text/javascript");e.setAttribute("async","true");e.setAttribute("src","https://widget.eu.usepylon.com/widget/APP_ID");var n=t.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};if(t.readyState==="complete"){r()}else if(e.addEventListener){e.addEventListener("load",r,false)}})(); </script>
Content Security Policy
If you have a CSP, you will need to set up the following policy:
Content-Security-Policy: connect-src 'self' https://*.usepylon.com wss://*.pusher.com; script-src 'self' https://widget.usepylon.com; font-src 'self' https://*.usepylon.com; style-src 'self' 'unsafe-inline' https://*.usepylon.com; img-src 'self' https://*.usepylon.com https://pylon-avatars.s3.us-west-1.amazonaws.com;If you are using EU data hosting, then use the following policy:
Content-Security-Policy: connect-src 'self' https://*.usepylon.com wss://*.pusher.com; script-src 'self' https://widget.eu.usepylon.com; font-src 'self' https://*.usepylon.com; style-src 'self' 'unsafe-inline' https://*.usepylon.com; img-src 'self' https://*.usepylon.com https://pylon-eucentral1-avatars.s3.eu-central-1.amazonaws.com;
Enable the Chat Widget
Anywhere in your React code you can access the
windowobject and set thepylonconfig.You should add this code wherever the user has already logged in and details like the User’s email, name, etc. become available.
Example usage in a React component:
Identity Verification
This is optional, but strongly recommended before you're ready for live production chats.
Turn it On
At the top of the Chat Widget Settings page on the Settings tab, toggle Enable Chat Widget on.
All Done!
Last updated
Was this helpful?

