Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/backend-message.js Secret
Created Nov 11, 2019

Embed
What would you like to do?
// backend/src/controllers/v1/message.js
const interpretMessage = async (eThree, publicKey, data) => {
const userId = data['user']['id'];
const message = await eThree.decrypt(data['message']['text'], publicKey);
const sessionClient = new dialogflow.SessionsClient();
const sessionPath = sessionClient.sessionPath(process.env.GOOGLE_APPLICATION_PROJECT_ID, sessions[userId]);
const responses = await sessionClient.detectIntent({
session: sessionPath,
queryInput: {
text: {
text: message,
languageCode: 'en-US',
},
},
});
return responses[0].queryResult;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.