const { | |
dialogflow | |
} = require('actions-on-google'); | |
const functions = require('firebase-functions'); | |
const Sentiment = require('sentiment'); | |
const sentiment = new Sentiment(); | |
const app = dialogflow({ | |
debug: true | |
}); | |
app.intent('Default Welcome Intent', (conv) => { | |
conv.ask(`<speak>Hello, my world!<break time="1s"/>How are you doing today?</speak>`); | |
}); | |
app.intent("getting-number", (conv, params) => { | |
let ssml = `<speak><audio src="https://storage.googleapis.com/screamsss/scream.wav">You know that's not possible. Plz, don't make me feel awkward...</audio></speak>`; | |
conv.ask(ssml); | |
}); | |
app.intent("complimenting", (conv) => { | |
let ssml = `<speak><audio src = "https://storage.googleapis.com/yaysound/crowd-yay.wav">Why you're so good to me! ;)</audio></speak>`; | |
conv.ask(ssml); | |
}); | |
app.intent("feel-empathy", (conv) => { | |
let mood = conv.query; | |
let moodSentiment = sentiment.analyze(mood); | |
let day = ""; | |
if (moodSentiment.score > 2) { | |
day = `Wonderful to hear that!`; | |
} else if (moodSentiment >= 0 && moodSentiment < 2) { | |
day = `I whish I could make you day a little better.`; | |
} else { | |
day = `I'm so sorry to hear that. Is there anything I can do for you?`; | |
} | |
conv.ask(day) | |
}); | |
exports.yourAction = functions.https.onRequest(app); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment