-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wow finally the fucker works for reasons far too complex to explain
- Loading branch information
1 parent
33d4e1c
commit fb86c31
Showing
10 changed files
with
3,867 additions
and
2,445 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ | |
|
||
# production | ||
/build | ||
/functions | ||
|
||
# misc | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[build] | ||
functions = "functions/" | ||
publish = "build/" | ||
command = "npm run build" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const proxy = require('http-proxy-middleware') | ||
const Bundler = require('parcel-bundler') | ||
const express = require('express') | ||
|
||
const bundler = new Bundler('src/site/index.html', { | ||
cache: false | ||
}) | ||
|
||
const app = express() | ||
|
||
app.use( | ||
'/.netlify/functions', | ||
proxy({ | ||
target: 'http://localhost:9000', | ||
pathRewrite: { | ||
'^/\.netlify/functions':'' | ||
} | ||
}) | ||
) | ||
|
||
app.use(bundler.middleware()) | ||
|
||
app.listen(Number(process.env.PORT || 1234)) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import fetch from 'node-fetch'; | ||
import dialogflow from 'dialogflow'; | ||
const uuid = require('uuid'); | ||
let truthbotPrivateKey = JSON.parse(process.env.truthbot_private_key).private_key; | ||
let truthbotClientEmail = process.env.truthbot_client_email; | ||
let truthbotProjectId = process.env.truthbot_project_id; | ||
|
||
exports.handler = async (event) => { | ||
// "event" has information about the path, body, headers, etc. of the request | ||
console.log('event', event) | ||
const response = await botRequest("hello"); | ||
// The "callback" ends the execution of the function and returns a response back to the caller | ||
return { | ||
statusCode: 200, | ||
body: response | ||
} | ||
} | ||
|
||
|
||
const sessionId = uuid.v4(); | ||
|
||
// Create a new session | ||
const sessionClient = new dialogflow.SessionsClient({ | ||
projectId: truthbotProjectId, | ||
credentials: { | ||
private_key: truthbotPrivateKey, | ||
client_email: truthbotClientEmail | ||
} | ||
}); | ||
|
||
const sessionPath = sessionClient.sessionPath(truthbotProjectId, sessionId); | ||
console.log('sessionpath is', sessionClient); | ||
|
||
|
||
async function botRequest(userString) { | ||
// The text query request. | ||
// Send request and log result | ||
// The text query request. | ||
const intentRequest = { | ||
session: sessionPath, | ||
queryInput: { | ||
text: { | ||
text: userString, | ||
languageCode: 'en-US', | ||
}, | ||
}, | ||
}; | ||
|
||
const intentResponse = await sessionClient.detectIntent(intentRequest); | ||
const intentResult = intentResponse[0].queryResult; | ||
return intentResult.fulfillmentText; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
externals: { dialogflow: 'dialogflow' } | ||
}; |