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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es6", | |
"module": "commonjs", | |
"strict": true | |
}, | |
"exclude": [ "node_modules" ] | |
} |
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
app.askWithCarousel( | |
// The input prompt. | |
{ | |
speech: 'Here are option A, option B and option C. To which one shpuld I react?', | |
displayText: 'Here are some options. To which option should I react?' | |
}, | |
// The carousel. | |
app.buildCarousel() | |
.addItems(['A', 'B', 'C'] | |
// Creates the option items. |
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
function buildOptionItem(app: DialogflowApp, aString: string): Responses.OptionItem { | |
// Provide a key which is unique to each option. | |
// And synonyms that the user can say alternativly to the title | |
return app.buildOptionItem(`KEY_${aString}`, aString) | |
.setTitle(`Option ${aString}`) | |
// Description and image are optional. | |
.setDescription(`Description for ${aString}`) | |
.setImage('https://example.com/image.jpg', 'An image') | |
} |
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
switch (app.getSelectedOption()) { | |
case 'KEY_A': | |
return app.tell('Option A is a solid choice.') | |
default: | |
return app.tell('I would prefer Option A.') | |
} |
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
let aLayout = optionsLabel.layoutGravitating(to: .right) |
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
let actionBar = [ | |
actionLabel, | |
optionsLabel.layoutGravitating(to: .right)] | |
.layoutAsFrame() | |
.layoutMatchingParentWidth() |
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
let actionBar = [ | |
actionLabel, | |
optionsLabel.layoutGravitating(to: .right)] | |
.layoutAsFrame() | |
.layoutMatchingParentWidth() | |
let posterDetails = [ | |
posterNameLabel, | |
posterHeadlineLabel, | |
posterTimeLabel] |
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
override func sizeThatFits(_ size: CGSize) -> CGSize { | |
return layout?.startMeasure(with: size) ?? .zero | |
} | |
override func layoutSubviews() { | |
layout?.startLayout(with: bounds) | |
} |
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 defaultIntents = [ | |
{ | |
intentName: 'AMAZON.HelpIntent', | |
handler: yourFunctionPointer | |
}, | |
// ... more Intents that are the same for each state. | |
] | |
const firstStateIntents = [ | |
{ |
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
function _FACT(num) { | |
var rval = 1; | |
for (var i = 2; i <= num; i++) { | |
rval = rval * i; | |
} | |
return rval; | |
}; | |
function _COMBIN(x, y) { | |
if (x < y) return 0; |