@tiledesk/tiledesk-tybot-connector 0.1.31 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -0
- package/package.json +2 -2
- package/test/conversation1-test.js +3 -3
- package/test/intent_form_test_.js_ +76 -0
- package/test/single_test.sh +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,9 @@
|
|
|
5
5
|
available on:
|
|
6
6
|
▶️ https://www.npmjs.com/package/@tiledesk/tiledesk-tybot-connector
|
|
7
7
|
|
|
8
|
+
### 0.1.32 - online
|
|
9
|
+
- @tiledesk/tiledesk-client => 0.8.42 - it now defaults to rejectUnauthorized=false for HTTPS connections
|
|
10
|
+
|
|
8
11
|
### 0.1.31 - online
|
|
9
12
|
- Fixed bot_answer["_raw_message"] moved to bot_answer.attributes.["_raw_message"]
|
|
10
13
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-tybot-connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.33",
|
|
4
4
|
"description": "Tiledesk Tybot connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@tiledesk/helpcenter-query-client": "^0.1.8",
|
|
15
15
|
"@tiledesk/tiledesk-chatbot-client": "^0.5.30",
|
|
16
16
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.38",
|
|
17
|
-
"@tiledesk/tiledesk-client": "^0.
|
|
17
|
+
"@tiledesk/tiledesk-client": "^0.9.1",
|
|
18
18
|
"axios": "^0.27.2",
|
|
19
19
|
"body-parser": "^1.19.0",
|
|
20
20
|
"cors": "^2.8.5",
|
|
@@ -52,7 +52,7 @@ after(function(done) {
|
|
|
52
52
|
describe('Conversation1', async() => {
|
|
53
53
|
|
|
54
54
|
it('/start', (done) => {
|
|
55
|
-
console.log("/start...ing story...");
|
|
55
|
+
// console.log("/start...ing story...");
|
|
56
56
|
let listener;
|
|
57
57
|
let endpointServer = express();
|
|
58
58
|
endpointServer.use(bodyParser.json());
|
|
@@ -110,7 +110,7 @@ describe('Conversation1', async() => {
|
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
it('/disable_input', (done) => {
|
|
113
|
-
console.log("/disable_input...");
|
|
113
|
+
// console.log("/disable_input...");
|
|
114
114
|
let listener;
|
|
115
115
|
let endpointServer = express();
|
|
116
116
|
endpointServer.use(bodyParser.json());
|
|
@@ -160,7 +160,7 @@ describe('Conversation1', async() => {
|
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('/good_form', (done) => {
|
|
163
|
-
console.log("/good_form...");
|
|
163
|
+
// console.log("/good_form...");
|
|
164
164
|
let listener;
|
|
165
165
|
let endpointServer = express();
|
|
166
166
|
endpointServer.use(bodyParser.json());
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
var assert = require('assert');
|
|
2
|
+
const { ExtUtil } = require('../ExtUtil');
|
|
3
|
+
const { IntentForm } = require('../models/IntentForm');
|
|
4
|
+
|
|
5
|
+
describe('IntentForm', function() {
|
|
6
|
+
|
|
7
|
+
it('basic form', async () => {
|
|
8
|
+
const form = {
|
|
9
|
+
"cancelCommands": ['annulla', 'cancella', 'reset', 'cancel'],
|
|
10
|
+
"cancelReply": "Ok annullato!",
|
|
11
|
+
"cancelReplyIntent": "formCanceled", // TODO IDEA
|
|
12
|
+
"fields": [
|
|
13
|
+
{
|
|
14
|
+
"name": "userFullname",
|
|
15
|
+
"type": "text",
|
|
16
|
+
"label": "What is your name?\n* Andrea\n* Marco\n* Mirco\n* Luca Leo"
|
|
17
|
+
},{
|
|
18
|
+
"name": "companyName",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"label": "Thank you ${userFullname}! What is your Company name?\n* Tiledesk\n* Frontiere21"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "userEmail",
|
|
24
|
+
"type": "text",
|
|
25
|
+
"regex": "/^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/",
|
|
26
|
+
"label": "Hi ${userFullname} from ${companyName}\n\nJust one last question\n\nYour email 🙂\n* andrea@libero.it\n* andrea@tiledesk.com",
|
|
27
|
+
"errorLabel": "${userFullname} this email address is invalid\n\nCan you insert a correct email address?"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class Chatbot {
|
|
33
|
+
async addParameter(requestId, parameter_name, parameter_value) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const PROJECT_ID = process.env.TEST_PROJECT_ID;
|
|
40
|
+
const REQUEST_ID = "support-group-" + PROJECT_ID + "-" + Date.now();
|
|
41
|
+
const BOT_ID = process.env.TEST_BOT_ID;
|
|
42
|
+
const CHATBOT_TOKEN = process.env.CHATBOT_TOKEN;
|
|
43
|
+
|
|
44
|
+
const chatbot = new Chatbot();
|
|
45
|
+
let request = {
|
|
46
|
+
"payload": {
|
|
47
|
+
"senderFullname": "guest",
|
|
48
|
+
"type": "text",
|
|
49
|
+
"sender": "A-SENDER",
|
|
50
|
+
"recipient": REQUEST_ID,
|
|
51
|
+
"text": "/good_form",
|
|
52
|
+
"id_project": PROJECT_ID,
|
|
53
|
+
"request": {
|
|
54
|
+
"request_id": REQUEST_ID,
|
|
55
|
+
"id_project": PROJECT_ID
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"token": CHATBOT_TOKEN
|
|
59
|
+
}
|
|
60
|
+
console.log("executing intent form...")
|
|
61
|
+
let intentForm = new IntentForm(
|
|
62
|
+
{
|
|
63
|
+
form: form,
|
|
64
|
+
requestId: REQUEST_ID,
|
|
65
|
+
chatbot: chatbot,
|
|
66
|
+
log: true
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
let message = await intentForm.getMessage(userInputReply);
|
|
70
|
+
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
package/test/single_test.sh
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
#npx mocha ./test/mock_query_test.js
|
|
3
3
|
#npx mocha ./test/disable_input_text_directive_test.js
|
|
4
4
|
#npx mocha ./test/close_directive_test.js
|
|
5
|
-
npx mocha ./test/conversation1-test.js --exit
|
|
5
|
+
#npx mocha ./test/conversation1-test.js --exit
|
|
6
|
+
npx mocha ./test/intent_form_test.js --exit
|