JavaScript Bindings for Userlike API
This is an experimental library written in TypeScript for accessing publicly available Userlike APIs.
There are several DTO classes located unter types. For example, the ChatMetaResponse contains an array of ChatMeta instances with several sub-classes, like Message, MessagesAndEvent, Organization, Note etc.
Classes |
---|
ChatMeta |
Message |
Operator |
Interfaces |
---|
Userlike |
ChatWidget => see also Config |
npm install
or
yarn install
To run the demo from index.ts type npm run start:client
.
Don't forget to put your API keys into src/config.json.
Your console output would then look like this:
To get a key you have to register first. There's a free, 14-day-limited subscription available.
npm test
Although not a part of the public API the ChatWidget class offers some interesting insights into the structure of the chat widget that can be integrated into own web pages. I discovered it accidentally while reading the automatically generated code of the chat client. To create this widget go to your Dashboard and select Config/Widgets
. After you've configured it select Install/JavaScript Widget Code
. An embeddable script-tag will show up. Now, open the URL from src in your browser.
You'll get a script similar to this one:
In the next step copy the base64-encoded string from data
property and decode it here.
You'll receive an output containing JSON data:
To get your data nicely formatted just go to JSONformatter.
The Chat Widget classes and their properties reflect the original JavaScript structures with one exception: the property chat_operator_text_color
in Theme class. In the original (decoded) source it contains a white space:
chat_operator_text color
I suppose that they access it only via bracket notation so the white space is not a real problem.
However, these classes are currently not in use. I'm using them only to learn a bit about their chat widget (and maybe hack it in the future...who knows?)