The Messenger JS-Client allows you to call an Inbenta API endpoint quickly and easily with javascript.
All examples shown are set in a Production environment.
Include the Inbenta Messenger SDK script somewhere in your page:
<script src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script>
Next, create a new client instance. To do so, you need your API Key (public key) and your domain key. See Finding your API credentials in the Help Center to obtain your credentials.
The following example shows a creation that uses a domain key.
var client = InbentaCMClient({ domain_key: '<your_domain_key>', api_key: '<your_API_Key>' }).build();
client.createTicket({ creator: { address:'<email_address>', extra:[], name:'<name>' }, message:'<message>' }).then(function(result){ console.log(result); });
<!doctype html> < lang="en"> <head> <script src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script> </head> <body> <script type="text/javascript"> var domain_key = '<your_domain_key>'; var api_key = '<your_API_key>'; var client = InbentaCMClient({ domain_key, api_key }).build(); client.createTicket({ creator: { address:'<email_address>', extra:[], name:'<name>' }, message:'<message>' }).then(function(result) { console.log(result); }); </script> </body> <html>
When you set up the SDK for your Inbenta product, you need to specify the version like this:
<script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script>
A subresource integrity hash table is available for this client here
Versions are written in MAJOR.MINOR.PATCH format.
Important:
Examples
<script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1/cm-js-client.js"></script>
<script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1.2/cm-js-client.js"></script>
<script integrity="<hash-type>-<hash>" crossorigin="anonymous" src="https://sdk.inbenta.io/cm/cm-js-client/1.2.3/cm-js-client.js"></script>
To create a new SDK instance, you need your API Key and a domain key. Contact your Inbenta representative to receive these credentials.
The methods page is available here.
Click here to see a list of API error codes.
client.createUser(data).catch(function (error) { if (error.response) { // The request was made and the server responded with a status code // that falls out of the range of 2xx console.log(error.response.data); console.log(error.response.status); console.log(error.response.headers); } else { // Something happened in setting up the request that triggered an Error console.log('Error', error.message); } });