Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2022-066
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
2022-066
2022-066
Commits
ce52f3ff
Commit
ce52f3ff
authored
Apr 26, 2022
by
Navodya Pasqual
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dialogflow backend
parent
e3fa89b0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
956 additions
and
2105 deletions
+956
-2105
Backend/Node/package-lock.json
Backend/Node/package-lock.json
+857
-2104
Backend/Node/package.json
Backend/Node/package.json
+4
-1
Backend/Node/server.js
Backend/Node/server.js
+5
-0
Backend/Node/src/config/chatbot/config.js
Backend/Node/src/config/chatbot/config.js
+8
-0
Backend/Node/src/modules/chatbot/Opinion.js
Backend/Node/src/modules/chatbot/Opinion.js
+12
-0
Backend/Node/src/routes/chatbot/dialogFlow.js
Backend/Node/src/routes/chatbot/dialogFlow.js
+70
-0
No files found.
Backend/Node/package-lock.json
View file @
ce52f3ff
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Backend/Node/package.json
View file @
ce52f3ff
...
...
@@ -20,7 +20,10 @@
"lodash"
:
"^4.17.21"
,
"mongoose"
:
"^6.0.8"
,
"nodeJS"
:
"^1.0.0"
,
"nodemon"
:
"^2.0.13"
"nodemon"
:
"^2.0.13"
,
"actions-on-google"
:
"^2.6.0"
,
"dialogflow"
:
"^0.10.2"
,
"dialogflow-fulfillment"
:
"^0.6.1"
},
"devDependencies"
:
{
"formidable"
:
"^1.2.2"
,
...
...
Backend/Node/server.js
View file @
ce52f3ff
...
...
@@ -4,6 +4,9 @@ const dotenv = require('dotenv');
const
cors
=
require
(
'
cors
'
);
const
bodyParser
=
require
(
'
body-parser
'
);
//Importing chatbot api
const
chatbotAPI
=
require
(
'
./src/routes/chatbot/dialogFlow
'
);
dotenv
.
config
();
const
app
=
express
();
app
.
use
(
cors
());
...
...
@@ -45,6 +48,8 @@ app.route('/').get((req, res) => {
require
(
'
./src/routes/auth.routes
'
)(
app
);
require
(
'
./src/routes/user.routes
'
)(
app
);
app
.
use
(
'
/api/dialogflow
'
,
chatbotAPI
);
app
.
listen
(
PORT
,
()
=>
{
console
.
log
(
'
######################################################
'
);
console
.
log
(
`Server is ON and running on PORT :
${
PORT
}
`
);
...
...
Backend/Node/src/config/chatbot/config.js
0 → 100644
View file @
ce52f3ff
module
.
exports
=
{
googleProjectID
:
'
test-chat-bot-app-348111
'
,
dialogFlowSessionID
:
'
bot-session
'
,
dialogFlowSessionLanguageCode
:
'
en-US
'
,
googleClientEmail
:
'
chat-bot-app-test@test-chat-bot-app-348111.iam.gserviceaccount.com
'
,
googlePrivateKey
:
"
-----BEGIN PRIVATE KEY-----
\n
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCkloXDObe/iKVG
\n
5VShLLT8X/qP+WUuL9pqkz+CbrbPMKpWVErRomsaUpvZzUnqRGGFizy9Q7jLdtBv
\n
JCBAhBq3Jdaeq+a0D2qt/gz2kTodbLKdWZ4WK4dXLRu4I+VhJWpu4W8ay5gDtHz/
\n
B7KI762QRSUuX58gnnPb9gg5692TtTzgKO+pRLpnTB36Jwb8uIcfE8S1VnmNPdM/
\n
Eb1XjeAEhFXBdpULq0aXrKm6bu0Vv3ON0bUzHUR3VhQR+fDYJfK7MmfxwvymXXCM
\n
AHReTVxuIGBUh6DSq/CrcyAZykIEewrLK3Yyyeiy/1cku2X3tG7+YGe8x0Eunvna
\n
mr1DaqgfAgMBAAECggEAKr4KW9Iz5VI7tccdrMOa9sWIIPaf75guzSmTPzC4WeMm
\n
AUhfq8RVsx7L6YqWDPgYKWGo8u/Q4EnpREup8oc8Ft8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afWfzo6tFKXGFL35CXCDcjfI6TZWvZItqsUd
\n
2A/zR9ExY/fjTFCE5tnZj+qJgLDI6bCN/cyB5SFA1EwFn5IPUHVzwCWM2qhq35qQ
\n
Rk6+eGP3mpMDg9Fp1fa6fnRi
\n
-----END PRIVATE KEY-----
\n
"
,
mongoURI
:
'
mongodb+srv://admin:admin123@db.i2rza.mongodb.net/myFirstDatabase?retryWrites=true&w=majority
'
,
}
\ No newline at end of file
Backend/Node/src/modules/chatbot/Opinion.js
0 → 100644
View file @
ce52f3ff
const
mongoose
=
require
(
'
mongoose
'
);
const
opinionSchema
=
mongoose
.
Schema
({
name
:
String
,
opinion
:
String
,
email
:
String
,
registerDate
:
Date
});
const
Opinion
=
mongoose
.
model
(
'
Opinion
'
,
opinionSchema
);
module
.
exports
=
{
Opinion
}
Backend/Node/src/routes/chatbot/dialogFlow.js
0 → 100644
View file @
ce52f3ff
const
express
=
require
(
'
express
'
);
const
router
=
express
.
Router
();
const
dialogflow
=
require
(
'
dialogflow
'
);
const
config
=
require
(
'
../../config/chatbot/config
'
);
const
projectId
=
config
.
googleProjectID
const
sessionId
=
config
.
dialogFlowSessionID
const
languageCode
=
config
.
dialogFlowSessionLanguageCode
const
credentials
=
{
client_email
:
config
.
googleClientEmail
,
private_key
:
config
.
googlePrivateKey
}
// Create a new session
const
sessionClient
=
new
dialogflow
.
SessionsClient
({
projectId
,
credentials
});
const
sessionPath
=
sessionClient
.
sessionPath
(
projectId
,
sessionId
);
router
.
post
(
'
/textQuery
'
,
async
(
req
,
res
)
=>
{
const
request
=
{
session
:
sessionPath
,
queryInput
:
{
text
:
{
// The query to send to the dialogflow agent
text
:
req
.
body
.
text
,
// The language used by the client (en-US)
languageCode
:
languageCode
,
},
},
};
// Send request and log result
const
responses
=
await
sessionClient
.
detectIntent
(
request
);
console
.
log
(
'
Detected intent
'
);
const
result
=
responses
[
0
].
queryResult
;
console
.
log
(
` Query:
${
result
.
queryText
}
`
);
console
.
log
(
` Response:
${
result
.
fulfillmentText
}
`
);
res
.
send
(
result
)
})
//Event Query Route
router
.
post
(
'
/eventQuery
'
,
async
(
req
,
res
)
=>
{
const
request
=
{
session
:
sessionPath
,
queryInput
:
{
event
:
{
// The query to send to the dialogflow agent
name
:
req
.
body
.
event
,
// The language used by the client (en-US)
languageCode
:
languageCode
,
},
},
};
// Send request and log result
const
responses
=
await
sessionClient
.
detectIntent
(
request
);
console
.
log
(
'
Detected intent
'
);
const
result
=
responses
[
0
].
queryResult
;
console
.
log
(
` Query:
${
result
.
queryText
}
`
);
console
.
log
(
` Response:
${
result
.
fulfillmentText
}
`
);
res
.
send
(
result
)
})
module
.
exports
=
router
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment