1.0.0 • Published 3 years ago
curai-js v1.0.0
curai-js
The Curai Health embedded experience JavaScript library
Usage
For a full guide on how to use this library, please see our Quickstart Guide.
CDN (https://unpkg.com/)
Example:
<html>
<head>
<script crossorigin type="text/javascript" src="https://unpkg.com/curai-js"></script>
</head>
<body>
<div id="”embedded-chat”" />
</body>
<script type="text/javascript">
Curai.startChatSession(clientId, accessToken, { parentElement: ... })
.then((frame) => {
// A valid session has started and the frame element is returned
})
.catch((err) => {
// An error has occurred
});
</script>
</html>See examples/script-tag-example.html for more.
Development
Getting Setup
yarnoryarn install
Start Developing
Open
examples/script-tag-example.htmlin your browser or w/ LiveServer- Make sure that the local script is loaded instead of the one hosted by unpkg
<script type="text/javascript" src="../dist/index.js"></script>
- Make sure that the local script is loaded instead of the one hosted by unpkg
Run
yarn startto have thecurai-jsmodule build on save
Connecting to the Curai frontend
- Run the frontend locally patient app guide
- In flask admin, go to the
Partnertable and use a partner with an API key.- Add a clientID to this entry (eg. "livingsalmon")
- Register a patient using the API
- Using your API key, craft a request following the gateway docs
- Grab the returned accessToken
- Inject your clientId and accessToken into the
examples/script-tag-example.htmlfile
After following these steps you should see the example page load into the patient app greeting your registered patient!
Publishing
- Login to Curai NPM account on local machine
- Run
yarn publishunpkg is pretty fast, but it can take a few minutes for the new version to be available