-
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev-google-action-responses'
- Loading branch information
Showing
46 changed files
with
3,207 additions
and
1,177 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
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
4 changes: 2 additions & 2 deletions
4
examples/indexAlexaDeviceAddress.js → ...alexa_specific/indexAlexaDeviceAddress.js
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
4 changes: 2 additions & 2 deletions
4
examples/indexAlexaLists.js → examples/alexa_specific/indexAlexaLists.js
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
4 changes: 2 additions & 2 deletions
4
examples/indexAlexaVerifier.js → ...ples/alexa_specific/indexAlexaVerifier.js
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
23 changes: 17 additions & 6 deletions
23
examples/indexRenderTemplate.js → ...les/alexa_specific/indexRenderTemplate.js
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
114 changes: 114 additions & 0 deletions
114
examples/google_action_specific/indexGoogleAssistantCards.js
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,114 @@ | ||
'use strict'; | ||
|
||
const webhook = require('../../index').Webhook; | ||
|
||
webhook.listen(3000, function() { | ||
console.log('Example server listening on port 3000!'); | ||
}); | ||
|
||
const app = require('../../index').Jovo; | ||
|
||
const BasicCard = require('../../index').GoogleAction.BasicCard; | ||
const Carousel = require('../../index').GoogleAction.Carousel; | ||
const List = require('../../index').GoogleAction.List; | ||
const OptionItem = require('../../index').GoogleAction.OptionItem; | ||
|
||
app.enableRequestLogging(); | ||
app.enableResponseLogging(); | ||
|
||
app.setIntentMap({ | ||
'Default Welcome Intent': 'HelloWorldIntent', | ||
}); | ||
|
||
// listen for post requests | ||
webhook.post('/webhook', function(req, res) { | ||
app.handleRequest(req, res, handlers); | ||
app.execute(); | ||
}); | ||
|
||
|
||
let handlers = { | ||
|
||
'LAUNCH': function() { | ||
app.toIntent('SuggestionsIntent'); | ||
// app.toIntent('ListIntent'); | ||
// app.toIntent('CarouselIntent'); | ||
}, | ||
'BasicCardIntent': function() { | ||
let basicCard = new BasicCard() | ||
.setTitle('Title') | ||
.setImage('https://via.placeholder.com/720x480', 'accessibilityText') | ||
.setFormattedText('Formatted Text'); | ||
|
||
app.googleAction().showBasicCard(basicCard); | ||
app.googleAction().showSuggestionChips(['List', 'Carousel', 'Basic card']); | ||
app.ask('Response with basic card', '?'); | ||
}, | ||
'SuggestionsIntent': function() { | ||
// must end with an ask response | ||
app.googleAction().showSuggestionChips(['List', 'Carousel', 'Basic card']); | ||
app.googleAction().showLinkOutSuggestion('Name', 'http://www.example.com'); | ||
app.ask('Choose one', 'Choose one'); | ||
}, | ||
'ListIntent': function() { | ||
let list = new List(); | ||
list.setTitle('Simple selectable List'); | ||
|
||
list.addItem( | ||
(new OptionItem()) | ||
.setTitle('Show a BasicCard') | ||
.setDescription('BasicCard') | ||
.setImage('https://via.placeholder.com/720x480', 'accessibilityText') | ||
.setKey('Listitem1key') | ||
); | ||
list.addItem( | ||
(new OptionItem()) | ||
.setTitle('Show a Carousel') | ||
.setDescription('Carousel') | ||
.setKey('Listitem2key') | ||
); | ||
app.googleAction().showList(list); | ||
app.googleAction().showSuggestionChips(['List', 'Carousel', 'Basic card']); | ||
app.ask('Choose from list', 'Choose from list'); | ||
}, | ||
'CarouselIntent': function() { | ||
let carousel = new Carousel(); | ||
|
||
carousel.addItem( | ||
(new OptionItem()) | ||
.setTitle('Show a BasicCard') | ||
.setDescription('BasicCard') | ||
.setImage('https://via.placeholder.com/720x480', 'accessibilityText') | ||
.setKey('Carouselitem1key') | ||
); | ||
carousel.addItem( | ||
(new OptionItem()) | ||
.setTitle('Show a List') | ||
.setDescription('Description2') | ||
.setImage('https://via.placeholder.com/720x480', 'accessibilityText') | ||
.setKey('Carouselitem2key') | ||
); | ||
app.googleAction().showCarousel(carousel); | ||
app.googleAction().showSuggestionChips(['List', 'Carousel', 'Basic card']); | ||
|
||
app.ask('Choose from list', 'Choose from list'); | ||
}, | ||
'HelloWorldIntent': function() { | ||
app.tell('Hello World'); | ||
}, | ||
'ON_ELEMENT_SELECTED': function() { | ||
let selectedElement = this.getSelectedElementId(); | ||
|
||
if (selectedElement === 'Listitem1key') { | ||
this.toIntent('BasicCardIntent'); | ||
} else if (selectedElement === 'Listitem2key') { | ||
this.toIntent('CarouselIntent'); | ||
} else if (selectedElement === 'Carouselitem1key') { | ||
this.toIntent('BasicCardIntent'); | ||
} else if (selectedElement === 'Carouselitem2key') { | ||
this.toIntent('ListIntent'); | ||
} else { | ||
this.tell(this.getSelectedElementId()); | ||
} | ||
}, | ||
}; |
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,50 @@ | ||
'use strict'; | ||
|
||
const webhook = require('../index').Webhook; | ||
|
||
webhook.listen(3000, function() { | ||
console.log('Example server listening on port 3000!'); | ||
}); | ||
|
||
const app = require('../index').Jovo; | ||
|
||
app.setConfig({ | ||
requestLogging: true, // default false | ||
responseLogging: true, // default false | ||
saveUserOnResponseEnabled: false, // default true | ||
userDataCol: 'otherColumnName', // default 'userData' | ||
inputMap: { // default {} | ||
'given-name': 'name', | ||
}, | ||
intentMap: { // default {} | ||
'AMAZON.StopIntent': 'StopIntent', | ||
}, | ||
requestLoggingObjects: ['session'], // default [] | ||
responseLoggingObjects: ['response'], // default [] | ||
saveBeforeResponseEnabled: true, // default false | ||
allowedApplicationIds: ['id1', 'id2'], // default [] | ||
userMetaData: { | ||
lastUsedAt: false, // default true | ||
sessionsCount: false, // default true | ||
createdAt: false, // default true | ||
requestHistorySize: 5, // default 0 | ||
devices: true, // default false | ||
}, | ||
}); | ||
|
||
// listen for post requests | ||
webhook.post('/webhook', function(req, res) { | ||
app.handleRequest(req, res, handlers); | ||
app.execute(); | ||
}); | ||
|
||
|
||
let handlers = { | ||
|
||
'LAUNCH': function() { | ||
app.tell('App launched'); | ||
}, | ||
'HelloWorld': function() { | ||
app.tell('Hello World'); | ||
}, | ||
}; |
Oops, something went wrong.