Alexa.Networking.AccessController Interface
Implement the Alexa.Networking.AccessController
interface in your Alexa skill so that users can enable or disable network access for a device that is connected to a home network controller. You can enable and disable internet and network access on both Wi-Fi and Ethernet connections, without removing devices from the Wi-Fi network. You can also use AccessController
to schedule access to the network. For an overview of the Alexa networking API, see Understand Networking and Wi-Fi Skills.
Before you test a skill that uses the AccessController
interface, make sure you use the Alexa app to add a device to the network you're testing with. For more details, see Overview of Wi-Fi Skills.
For the list of languages that the AccessController
interface supports, see List of Alexa Interfaces and Supported Languages.
Utterances
When you use the Alexa.Networking.AccessController
interface, the voice interaction model is already built for you. The following examples show some customer utterances:
Alexa, pause Wi-Fi for John's tablet.
Alexa, pause internet for Jane's computer.
Alexa, enable the Wi-Fi for Junior's tablet for thirty minutes.
Alexa, enable the internet for Junior's phone for three hours.
After the customer says one of these utterances, Alexa sends a corresponding directive to your skill.
Properties
The Alexa.Networking.AccessController
interface uses the networkAccess
property to represent whether an endpoint can connect to the network. The following are the valid network access values:
Value | Description |
---|---|
ALLOWED |
The endpoint can connect to the network. |
BLOCKED |
The endpoint cannot connect to the network. |
The Alexa.Networking.AccessController
interface uses the schedule
field in the SetNetworkAccess
directive to represent when network access should be enabled or disabled, and for how long. This field is expressed as a TimeInterval. If the user doesn't specify a schedule, enable or disable network access immediately.
Discovery
You describe endpoints that support Alexa.Networking.AccessController
using the standard discovery mechanism described in Alexa.Discovery.
Set retrievable
to true for all of the interfaces and properties that you report when Alexa sends your skill a state report request.
The friendlyName
field is optional for this interface. If the user sets a name for a device in your app, then provide that name in your discover response; otherwise, don't include friendlyName
.
For the full list of display categories, see display categories.
In addition to the usual discovery response fields, for AccessController
, include a configuration object that contains the following fields.
Field | Description | Type | Required |
---|---|---|---|
supportsScheduling |
If true indicates that the user can schedule network access for the endpoint. | Boolean | No |
Discover response example
The following example shows a Discover.Response
message for a mobile phone that supports the ConnectedDevice
and AccessController
interfaces.
{
"event": {
"header": {
"namespace": "Alexa.Discovery",
"name": "Discover.Response",
"payloadVersion": "3",
"messageId": "<message id>"
},
"payload": {
"endpoints": [
{
"endpointId": "<unique ID of the endpoint>",
"manufacturerName": "<the manufacturer name of the endpoint>",
"description": "<a description that is shown in the Alexa app>",
"friendlyName": "<the friendly name of the endpoint, optional for this interface>",
"displayCategories": ["MOBILE_PHONE"],
"cookie": {},
"relationships": {
"isConnectedBy": {
"endpointId": "<unique ID of the home network endpoint>"
}
},
"capabilities": [
{
"type": "AlexaInterface",
"interface": "Alexa.Networking.ConnectedDevice",
"version": "3",
"configuration": {
"firstConnectionTime": "2018-05-30T08:15Z",
"staticDeviceInformation": {
"deviceName": "Personal cell phone",
"hostname": "Pixel XL",
"brand": "Google",
"model": "Pixel XL",
"operatingSystem": "Android 10",
"macAddress": "00:09:5B:EC:EE:F2",
"dhcpFingerprint": "1,15,3,6,44,46,47,31,33,249,43",
"dhcp6Fingerprint": "1,15,3,6,44,46,47,31,33,249,43,252,12"
}
}
},
{
"type": "AlexaInterface",
"interface": "Alexa.Networking.AccessController",
"version": "3",
"properties": {
"supported": [
{
"name": "networkAccess",
}
],
"proactivelyReported": true,
"retrievable": true
},
"configuration": {
"supportsScheduling": true
}
},
{
"type": "AlexaInterface",
"interface": "Alexa",
"version": "3"
}
]
}
]
}
}
}
Directives
SetNetworkAccess directive
Support the SetNetworkAccess
directive so that customers can enable or disable network access for a device.
The following examples show customer utterances:
Alexa, paus Wi-Fi for John's tablet.
Alexa, enable the Wi-Fi for Junior's tablet for thirty minutes.
SetNetworkAccess directive payload details
Field | Description | Type |
---|---|---|
networkAccess |
Whether to enable or disable network access; one of ALLOWED or BLOCKED . |
String |
schedule |
The time and duration to enable or disable network access. If schedule is omitted, enable or disable network access immediately. You identify whether you support scheduling in your discover response. | A TimeInterval object. |
SetNetworkAccess directive example
The following example illustrates a SetNetworkAccess
directive that Alexa sends to your skill.
{
"directive": {
"header": {
"namespace": "Alexa.Networking.AccessController",
"name": "SetNetworkAccess",
"messageId": "<message id>",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "<endpoint id>",
"cookie": {}
},
"payload": {
"networkAccess": "BLOCKED",
"schedule": {
"duration": "PT30M"
}
}
}
}
SetNetworkAccess response event
If you handle a SetNetworkAccess
directive successfully, respond with an Alexa.Response event. In the context object, include the values of all relevant properties. You can respond synchronously or asynchronously. If you respond asynchronously, include a correlation token and a scope with an authorization token.
SetNetworkAccess response event example
The following example shows a response to a SetNetworkAccess
directive.
{
"event": {
"header": {
"namespace": "Alexa",
"name": "Response",
"messageId": "<message id>",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "<endpoint id>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.Networking.AccessController",
"name": "networkAccess",
"value": "BLOCKED",
"timeOfSample": "2019-10-15T14:15:00Z",
"uncertaintyInMilliseconds": 0
},
]
}
}
SetNetworkAccess directive error handling
If you can't handle a SetNetworkAccess
directive successfully, respond with an Alexa.ErrorResponse event.
State reporting
Alexa sends a ReportState
directive to request information about the state of an endpoint. When Alexa sends a ReportState
directive, you send a StateReport
event in response. The response contains the current state of all of the retrievable properties in the context object. You identify your retrievable properties in your discovery response. For details about state reports, see Understand State and Change Reporting.
StateReport response event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "StateReport",
"messageId": "<message id>",
"correlationToken": "<an opaque correlation token>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "<endpoint id>"
},
"payload": {}
},
"context": {
"properties": [
{
"namespace": "Alexa.Networking.AccessController",
"name": "networkAccess",
"value": "BLOCKED",
"timeOfSample": "2019-10-15T14:15:00Z",
"uncertaintyInMilliseconds": 0
},
]
}
}
Change reporting
You send a ChangeReport
event to proactively report changes in the state of an endpoint. You identify the properties that you proactively report in your discovery response. For details about change reports, see Understand State and Change Reporting.
ChangeReport event example
{
"event": {
"header": {
"namespace": "Alexa",
"name": "ChangeReport",
"messageId": "<message id>",
"payloadVersion": "3"
},
"endpoint": {
"scope": {
"type": "BearerToken",
"token": "<an OAuth2 bearer token>"
},
"endpointId": "<endpoint id>"
},
"payload": {
"change": {
"cause": {
"type": "APP_INTERACTION"
},
"properties": [
{
"namespace": "Alexa.Networking.AccessController",
"name": "networkAccess",
"value": "ALLOWED",
"timeOfSample": "2019-10-15T14:20:00Z",
"uncertaintyInMilliseconds": 0
}
]
}
}
},
"context": {}
}