Skip to content

Instantly share code, notes, and snippets.

View silvolu's full-sized avatar

Silvano Luciani silvolu

View GitHub Profile
@silvolu
silvolu / media-example2.xml
Created December 6, 2017 19:25
Second example of SSML media element.
<speak>
<par>
<media xml:id='question'>
<speak>
When was Wikipedia launched? <break time='5s'/>
Was it 2000?<break time='2s'/>
Or 2001 <break time='2s'/>
Or 2002? <break time='2s'/>
What is your answer?<break time='5s'/>
<emphasis level="moderate">It was 2001!</emphasis>
@silvolu
silvolu / v2-framworks-express.js
Created March 17, 2018 00:42
Publish Actions on Google V2 apps from self-hosted express
const express = require('express')
const bodyParser = require('body-parser')
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
express().use(bodyParser.json(), app).listen(3000)
@silvolu
silvolu / idtoken_sample.js
Last active September 17, 2018 17:36
IdToken content sample
{
// The unique ID of the user's Google Account
"sub": 1234567890,
// The token's issuer
"iss": "https://accounts.google.com",
// Client ID assigned to your Actions project
"aud": "123-abc.apps.googleusercontent.com",
// Unix timestamp of the token's creation time
"iat": 233366400,
// Unix timestamp of the token's expiration time
@silvolu
silvolu / v2-framworks-lambda.js
Created March 17, 2018 00:41
Publish Actions on Google V2 apps from AWS Lambda
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
exports.factsAboutGoogle = app
@silvolu
silvolu / v2-frameworks.js
Created March 13, 2018 21:15
Publish Actions on Google V2 apps from different frameworks
// Cloud Functions for Firebase
const functions = require('firebase-functions')
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
exports.factsAboutGoogle = functions.https.onRequest(app)
// AWS Lambda
@silvolu
silvolu / v2-framworks-cff.js
Created March 17, 2018 00:40
Publish Actions on Google V2 apps from Cloud Functions for Firebase
const functions = require('firebase-functions')
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
exports.factsAboutGoogle = functions.https.onRequest(app)
@silvolu
silvolu / v2-conv-close.js
Last active March 16, 2018 19:35
Use conv.close in the Actions on Google client library v2.
app.intent('Default Welcome Intent', conv => {
conv.close('Thanks for talking to me!')
})
@silvolu
silvolu / v2-conv-ask.js
Last active March 16, 2018 16:12
Calling ask multiple times
app.intent('tell.greeting', (conv, { color, num }) => {
conv.ask(`Dialogflow likes ${color}`, new Suggestions('Ok', 'Cool'))
conv.ask(new BasicCard({
title: 'Card Title',
image: { // Mostly, provide anonymous Objects
url: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png',
accessibilityText: 'Google Logo',
},
buttons: new Button({ // Wrapper for complex sub Objects, but can also use Objects when needed
title: 'Button Title',
@silvolu
silvolu / v2-plugins.js
Last active March 16, 2018 16:10
Using plugins with Actions on Google client library v2
const { dialogflow } = require('actions-on-google')
const { randomize, Randomization } = require('randomize')
const app = dialogflow()
.use(randomize)
app.intent('tell.greeting', conv => {
conv.ask(`The last thing I told you was ${conv.randomize.last}`)
conv.ask(new Randomization(
'How are you?',
@silvolu
silvolu / v2-no-builders.js
Created March 13, 2018 21:24
Comparison between creating a BasicCard in v1 and in v2
// v1
app.buildRichResponse(
app.buildBasicCard('some string')
.setImage('https://site.com/img.png', 'some other string'))
// v2
conv.ask(new BasicCard({
title: 'some string',
image: {
url: 'https://site.com/img.png',