The Assist JS-Client allows you to call an Inbenta API endpoint quickly and easily with javascript.
Note: All examples shown are set in a Production environment.
Steps to follow:
Integration
Include the Inbenta Assist SDK script somewhere in your page:
<script src="https://sdk.inbenta.io/cm/cm-js-client/<version>/cm-js-client.js"></script>
Creation
Next, create a new client instance. To do so, you will 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 using a domain key.
var client = InbentaCmClient({ domain_key: '<your_domain_key>', api_key: '<your_API_Key>' }).build();
Use client
client.createTicket({
creator: {
address:'<email_address>',
extra:[],
name:'<name>'
},
message:'<message>'
}).then(function(result){
console.log(result);
});
Important Please keep in mind that Inbenta APIs accept HTTPS requests only. If you need to send API requests using other protocols, the only way to do this is to set up a proxy to convert those protocols to the HTTPS protocol before the requests reach the API.
Example
<!doctype html>
<!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>
Note: 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.
All JS Client methods are described 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);
}
});