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
yarn
oryarn install
Start Developing
Open
examples/script-tag-example.html
in 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 start
to have thecurai-js
module build on save
Connecting to the Curai frontend
- Run the frontend locally patient app guide
- In flask admin, go to the
Partner
table 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.html
file
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 publish
unpkg is pretty fast, but it can take a few minutes for the new version to be available