@@ -1383,6 +1383,107 @@ class TiledeskClient {
1383
1383
) ;
1384
1384
}
1385
1385
1386
+ // *******************************************************
1387
+ // *********************** Intents ***********************
1388
+ // *******************************************************
1389
+
1390
+ /**
1391
+ * Create an Intent (aka Faq).<br>
1392
+ * <a href='https://developer.tiledesk.com/apis/rest-api/chat-bots/faq#create-a-new-faq' target='_blank'>REST API</a>
1393
+ * @param {string } botId - The botId. Mandatory
1394
+ * @param {string } intent_display_name - Intent Display Name
1395
+ * @param {string } question - The question
1396
+ * @param {string } answer - The answer
1397
+ * @param {string } language - The bot language
1398
+ * @param {boolean } webhook_enabled - Is fulfillment enabled for this intent?
1399
+ * @param {resultCallback } callback - The callback that handles the response.
1400
+ */
1401
+ createIntent ( botId , intentDisplayName , question , answer , language , webhook_enabled , callback ) {
1402
+ console . log ( "createIntent 1" )
1403
+ const URL = `${ this . APIURL } /${ this . projectId } /faq`
1404
+ const HTTPREQUEST = {
1405
+ url : URL ,
1406
+ headers : {
1407
+ 'Content-Type' : 'application/json' ,
1408
+ 'Authorization' : this . jwt_token
1409
+ } ,
1410
+ json : {
1411
+ id_faq_kb : botId ,
1412
+ intent_display_name : intentDisplayName ,
1413
+ question : question ,
1414
+ answer : answer ,
1415
+ language : language ,
1416
+ webhook_enabled : webhook_enabled
1417
+ } ,
1418
+ method : 'POST'
1419
+ } ;
1420
+ console . log ( "createIntent 2" )
1421
+ TiledeskClient . myrequest (
1422
+ HTTPREQUEST ,
1423
+ function ( err , resbody ) {
1424
+ if ( err ) {
1425
+ if ( callback ) {
1426
+ console . log ( "createIntent 3" )
1427
+ callback ( err ) ;
1428
+ }
1429
+ }
1430
+ else {
1431
+ console . log ( "createIntent 5" )
1432
+ if ( callback ) {
1433
+ console . log ( "createIntent 4" )
1434
+ callback ( null , resbody ) ;
1435
+ }
1436
+ }
1437
+ } , this . log
1438
+ ) ;
1439
+ }
1440
+
1441
+ /**
1442
+ * Get bot intents, filtered by parameters<br>
1443
+ * <a href='https://developer.tiledesk.com/apis/rest-api/chat-bots/faq#get-all-faqs-of-a-bot' target='_blank'>REST API</a>
1444
+ * @param {string } id_faq_kb - The bot's id. Mandatory.
1445
+ * @param {string } intent_display_name - Filter by Intent Display Name. Optional
1446
+ * @param {number } page - page number for pagination. Optional
1447
+ * @param {number } limit - results per page. Optional
1448
+ * @param {string } text - executes a full text search on this parameter. Optional
1449
+ * @param {resultCallback } callback - The callback that handles the response.
1450
+ */
1451
+ getIntents ( id_faq_kb , intent_display_name , page , limit , text , callback ) {
1452
+ const URL = `${ this . APIURL } /${ this . projectId } /faq`
1453
+ const params = {
1454
+ id_faq_kb : id_faq_kb ,
1455
+ intent_display_name : intent_display_name ,
1456
+ page : page ,
1457
+ limit : limit ,
1458
+ text : text
1459
+ } ;
1460
+ console . log ( "querying params:" , params ) ;
1461
+ const HTTPREQUEST = {
1462
+ url : URL ,
1463
+ headers : {
1464
+ 'Content-Type' : 'application/json' ,
1465
+ 'Authorization' : this . jwt_token
1466
+ } ,
1467
+ params : params ,
1468
+ method : 'GET'
1469
+ } ;
1470
+ TiledeskClient . myrequest (
1471
+ HTTPREQUEST ,
1472
+ function ( err , resbody ) {
1473
+ if ( err ) {
1474
+ if ( callback ) {
1475
+ callback ( err ) ;
1476
+ }
1477
+ }
1478
+ else {
1479
+ if ( callback ) {
1480
+ callback ( null , resbody ) ;
1481
+ }
1482
+ }
1483
+ } , true
1484
+ ) ;
1485
+ }
1486
+
1386
1487
// ***********************************************************
1387
1488
// *********************** DEPARTMENTS ***********************
1388
1489
// ***********************************************************
@@ -1668,7 +1769,7 @@ class TiledeskClient {
1668
1769
}
1669
1770
1670
1771
/**
1671
- * Returns the current opening status based on Opening Hours.
1772
+ * Returns the current opening status based on Opening Hours (aka Operating hours) .
1672
1773
*
1673
1774
* @param {resultCallback } callback - The callback that handles the response.<br>
1674
1775
* <a href='https://developer.tiledesk.com/apis/rest-api/projects#return-if-the-project-is-open-regarding-operating-hours' target='_blank'>REST API</a>
@@ -2247,14 +2348,14 @@ class TiledeskClient {
2247
2348
url : options . url ,
2248
2349
method : options . method ,
2249
2350
data : options . json ,
2351
+ params : options . params ,
2250
2352
headers : options . headers
2251
2353
} )
2252
2354
. then ( function ( res ) {
2253
2355
if ( log ) {
2254
2356
console . log ( "Response for url:" , options . url ) ;
2255
2357
console . log ( "Response headers:\n" , res . headers ) ;
2256
- console . log ( "******** Response for url:" , res ) ;
2257
- console . log ( "Response body:\n" , res . data ) ;
2358
+ //console.log("******** Response for url:", res);
2258
2359
}
2259
2360
if ( res && res . status == 200 && res . data ) {
2260
2361
if ( callback ) {
0 commit comments