Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Sv translation
languagecs_CZ


Table of Contents
indent10px

Uvod do Daktela JS Integracii

Daktela umoznuje integraciu s aplikaciami postavenymi v prehliadaci kde mozete ovladat stav uzivatela od jednoduchych akcii ako je napriklad prihlasit alebo odhlasit uzivatela az po spravovanie hovorov, posielanie sms alebo vytvarat tickety. Pre integraciu sa pouziva API, ktora podporuje JSONP alebo vam mozeme povolit JSON pre Cross-Origin Resource Sharing. Authorizacia na API sa robi pomocou accessToken kluca, ktory je pre kazdeho uzivatela jedinecny a moze sa posielat v requeste ako hodnota, v cookie alebo v hlavicke pod nazvom X-Auth-Token. Tieto akcie mozete volat rucne alebo vyuzit CLI kniznicu ktora je momentalne len v experimentalnej podobe.

Ako prihlasit uzivatela do fronty

Fronty sluzia na spravovanie jednotlivych kanalov ako su napriklad webchat, hovory, sms, atd. Aby mohol uzivatel spravit odchodzi hovor musi byt prihlaseny v hovorovej fronte. Viac o tychto akciach v API

Code Block
languagejs
firstline1
linenumberstrue
// 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);

Ako vytvorit hovor pre uzivatela

Pre vytvorenie hovoru musite mat accessToken uzivatela, ktory ma pravo volat alebo pravo na uzivatela ktory moze volat ak by ste chceli vytovorit hovor inemu uzivatelovi. Viac o tychto akcia v API

Code Block
languagejs
firstline1
linenumberstrue
// 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
});

Ako zistit aktualny stav uzivatela

Ak potrebuje v svojej aplikacii zobrazovat aktualny stav uzivatela v daktele teda ci ma prebiehajuci hovor alebo je na pauze ci v ktorych frontach je prihlaseny. Dotaz moze byt jednorazovy alebo vyuzit  HTTP Long Polling dotaz tak ze sa posle parameter hash a po odpovedi sa do hash vlozi hodnota hashu ktoru vratil server ktory sluzi na detekciu zmien. Viac o tomto dotaze v API

Code Block
languagejs
firstline1
linenumberstrue
// 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
});

Priklad jednoduchej integracie

Tento priklad ukazuje ako spravit applikaciu, ktora umoznuje prihlasit uzivatela a ovladat jeho pauzu. Rucne volanie index.html, vyuzitie CLI index_cli.html

Sv translation
languageen_US

Table of Contents
indent10px

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

Code Block
languagejs
firstline1
linenumberstrue
// 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

Code Block
languagejs
firstline1
linenumberstrue
// 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

Code Block
languagejs
firstline1
linenumberstrue
// 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