Note: this package is under development, you should no rely on this for production.
So that you dont need to write boilerplate code for Alexa Home Skill with Nodejs.
Alehos support routing for the Smart Home Skill API v3.
let Alehos = require('alehos3')
let alehos = new Alehos()
alehos.registerHandler('discover', (req, cb) => {
// get the payload
// const payload = { ... }
cb(null, null, payload)
})
alehos.registerHandler('powerControllerTurnOn', (req, cb) => {
// action ...
// finally return OK
cb(null)
})
exports.handler = function(event, context, cb) {
alehos.handle(event, context, cb)
}
discover
: discoverypowerControllerTurnOn
: turn onpowerControllerTurnOff
: turn offauthorization
: Alexa.Authorization Interface
If you don't provide equivalent function, the response will be INVALID_DIRECTIVE
.
req
is actually the event
and context
object from lambda request. You should looking at event for request message.
cb
is the response function.
If you want to return error, generate an new error object, with payload of the intented error. Example:
// if the device is un reachable
let err = new Error()
err.payload = {
type: alehos.code.ERR_ENDPOINT_UNREACHABLE,
message: 'device is unreachable'
}
return cb(err)
- support all functions
- set/get the event function
MIT