This file contains hidden or 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
| sentimentAnalysis: function (text, id) { | |
| var deferred = $.Deferred(); | |
| $.ajax({ | |
| method: "POST", | |
| url: comprehendFunctionURI, | |
| data: JSON.stringify({ | |
| "data": { | |
| "text": text, | |
| "comprehend": { |
This file contains hidden or 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
| const xhr = require('xhr'); | |
| const vault = require('vault'); | |
| export default (request, response) => { | |
| let body; | |
| let classifier; | |
| let input; | |
| /** | |
| * Validate the request. |
This file contains hidden or 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
| var AWS = require('aws-sdk'); | |
| AWS.config.update({ | |
| accessKeyId: "__id__", | |
| secretAccessKey: "__secret__", | |
| }); | |
| var lexruntime = new AWS.LexRuntime({region: 'us-east-1'}); | |
This file contains hidden or 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
| const me = { | |
| name: 'John Smith', | |
| uuid: '12345', // Can be a valid UUID, as long as it's a string | |
| }; | |
| ChatEngine.connect(me.uuid, me); |
This file contains hidden or 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
| chat.emit('custom-event', {value: true}); | |
| chat.on('custom-event', (payload) => { | |
| console.log(payload.sender.uuid, 'emitted the value', payload.data.value); | |
| }); |
This file contains hidden or 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
| const aliceBobPrivateChat = new ChatEngine.Chat('alice-bob-channel', true); | |
| aliceBobPrivateChat.emit('message', { | |
| text: 'Hey!' | |
| }); |
This file contains hidden or 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
| chat.emit('message', { | |
| text: "This is the chatbot speaking :]", | |
| }); | |
| // Separate into 2 snippets | |
| chat.on('message', (payload) => { | |
| chatLog.append(payload.text); | |
| }); |
This file contains hidden or 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
| // Get the message history in the global chat | |
| globalChat.search({ | |
| event: 'message', | |
| limit: 6, | |
| }); |
This file contains hidden or 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
| // Libs | |
| const PubNub = require('pubnub'); | |
| const Web3 = require('web3'); | |
| const ContractBuild = require('PATH_TO_TRUFFLE/build/contracts/Token.json'); | |
| // PubNub | |
| pubnub = new PubNub({ | |
| publishKey : '__YOUR_PUB_KEY__', | |
| subscribeKey : '__YOUR_SUB_KEY__' | |
| }); |
This file contains hidden or 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
| ## Get the Vue CLI | |
| npm i vue -g | |
| ## Create a new Vue app | |
| ## Chose whichever settings you want using the Vue CLI | |
| vue init webpack chat-app | |
| cd chat-app | |
| npm i vuex vue-chat-engine chat-engine chat-engine-typing-indicator |