Created
November 23, 2018 14:41
-
-
Save pschild/1c3d4c7b35510d7b6a2b00443a3c7674 to your computer and use it in GitHub Desktop.
alexa-button-input-handler
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
alexaApp.on('GameEngine.InputHandlerEvent', (request: alexa.request, response: alexa.response) => { | |
response.say('Button pressed'); | |
}); |
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
import * as alexa from 'alexa-app'; | |
export default (request: alexa.request, response: alexa.response): Promise<alexa.response> => { | |
const r = response | |
.directive({ | |
type: 'GameEngine.StartInputHandler', | |
timeout: 10000, | |
proxies: ['left'], | |
recognizers: { | |
all_pressed: { | |
type: 'match', | |
fuzzy: true, | |
anchor: 'start', | |
pattern: [ | |
{ | |
gadgetIds: ['left'], | |
action: 'down' | |
} | |
] | |
} | |
}, | |
events: { | |
complete: { | |
meets: ['all_pressed'], | |
reports: 'matches', | |
shouldEndInputHandler: true | |
}, | |
failed: { | |
meets: ['timed out'], | |
reports: 'history', | |
shouldEndInputHandler: true | |
} | |
} | |
}) | |
.say('You have 10 seconds to press a button') | |
.shouldEndSession(false); | |
return r.send(); | |
}; |
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
{ | |
"manifest": { | |
"publishingInformation": { | |
"gadgetSupport": { | |
"requirement": "REQUIRED", | |
"numPlayersMin": 1, | |
"numPlayersMax": 1, | |
"minGadgetButtons": 1, | |
"maxGadgetButtons": 1 | |
} | |
}, | |
"apis": { | |
"custom": { | |
"interfaces": [ | |
{ | |
"type": "GAME_ENGINE" | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment