Page tree
Skip to end of metadata
Go to start of metadata

Introduce to Daktela JS integrations

Daktela allows integration with browser-based applications where you can manage user state from simple action such as login or logout user to manage calls, send sms or create tickets. For integration we use API that supports JSONP or we can enable JSON for Cross-Origin Resource Sharing. For API authorization we use accessToken key which is unique for any user and can be send as value in request, in cookie or header in name X-Auth-Token. You can call these actions manually or you can use our CLI libary which is now in beta.

How to log in user to queue

The queues are for manage individual channels such as calls, webchats, smses, etc. If user want get inbound or make outbound calls, sms must be logged in queue. More about this requests in API

// Log in user to queue 2000 with penalty 0
$.post("https://<pbx_name>.daktela.com/api/v6/usersSession.json", {
	accessToken: "<accessToken>",
	queues: [
		{login: true, name: 2000, penalty: 0}
	]
});

// Init CLI
var cli = new daktelaCLI();
cli.init({
	host: "https://<pbx_name>.daktela.com",
	accessToken: "<accessToken>"
});

// Called with CLI
cli.userSessions.queue(2000, true, 0);

How to make a call for user

For make a call you must have rights to create call and be logged in to outbound call queue or have rights on user with this rights if you want make a call to another user. More about this requests in API

// Create call on number 123456789 in queue 2000 for acl user
$.post("https://<pbx_name>.daktela.com/api/v6/activities.json", {
	accessToken: "<accessToken>",
	number: "123456789",
	type: "CALL",
	queue: 2000
});


// Called with CLI
cli.activities.call.dial({
	number: "123456789",
	queue: 2000
});

How to get current user state

If you need in your application show user current daktela state, means it user has call, is on pause or in which queues is logged use api request on appPullData. Request can be simple one time called or used as HTTP Long Polling request.. More about this request in API

// Get dynamic data for acl user
$.get("https://<pbx_name>.daktela.com/api/v6/appPullData.json?accessToken=<accessToken>&hash=<hash>").done(function (response) {
	// In response you get structured dynamic data for acl user
});

// Called with CLI
cli.appPullData("<hash>", function (response) {
	// Success response
});

Example simple integration

This example show how to create simple application which can log in user and change his pause. Manual example index.html, example using CLI index_cli.html

  • No labels