感谢您的访问。此页面目前仅提供英语版本。我们正在开发中文版本。谢谢您的理解。

Alexa.Cooking Interface

The Alexa.Cooking capability interface describes messages used to control cooking appliances. All cooking appliances should implement the Cooking interface. For more information about cooking skills, see Build Smart Home Skills for Cooking Appliances.

For the list of locales that are supported for the Cooking interface, see List of Capability Interfaces and Supported Locales.

Utterances

When you use the Alexa.Cooking interface, the voice interaction model is already built for you. The following examples show some customer utterances:

Alexa, defrost three pounds of meat in my microwave.

After the customer says one of these utterances, Alexa sends a corresponding directive to your skill.

Properties

The Alexa.Cooking interface uses the following properties.

Property Description Type
cookingMode The cooking mode for a cooking session, such as REHEAT. A cookingMode object or string.
foodItem The food to cook. A foodItem object.
cookStartTime The time that cooking starts. A DateTime object.
cookCompletionTime The time that cooking completes. A DateTime object.
isCookCompletionTimeEstimated Indicates whether cookCompletionTime is estimated or actual. The default is false. Boolean

Discovery

You describe endpoints that support Alexa.Cooking 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. Set proactivelyReported to true for interfaces and properties that you proactively report to Alexa in a change report.

For the full list of display categories, see display categories.

In addition to the usual discovery response fields, for the Cooking interface, include a configuration object that contains the following fields.

Field Description Type Required
supportsRemoteStart True if Alexa can start the device after a customer's voice command. When false, Alexa prompts the user to push start on the device. The default is false. Boolean No
supportedCookingModes The cooking modes that the device supports. Include OFF, and specify the default cooking mode as the first item in the array. An array of cookingMode values. Yes

Discover response example

The following example shows a Discover.Response message for a microwave endpoint that supports the Alexa.Cooking and Alexa.PowerController 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": "Microwave",
          "displayCategories": ["MICROWAVE"],
          "cookie": {},
          "capabilities": [
            {
              "type": "AlexaInterface",
              "interface": "Alexa",
              "version": "3"
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa.Cooking",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "cookingMode"
                  },
                  {
                    "name": "foodItem"
                  },
                  {
                    "name": "cookStartTime"
                  },
                  {
                    "name": "cookCompletionTime"
                  },
                  {
                    "name": "isCookCompletionTimeEstimated"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              },
              "configuration": {
                "supportsRemoteStart": false,
                "supportedCookingModes": ["OFF", "DEFROST", "REHEAT"]
              }
            },
            {
              "type": "AlexaInterface",
              "interface": "Alexa.PowerController",
              "version": "3",
              "properties": {
                "supported": [
                  {
                    "name": "powerState"
                  }
                ],
                "proactivelyReported": true,
                "retrievable": true
              }
            }
          ]
        }
      ]
    }
  }
}

Directives

SetCookingMode directive

Support the SetCookingMode directive so that customers can set the cooking mode for a device.

The following example shows a customer utterance:

Alexa, defrost three pounds of meat in my microwave.

SetCookingMode directive payload details

Field Description Type
cookingMode The cooking mode for the cooking session, such as DEFROST. A cookingMode object or string.
foodItem The food to cook. This field is only included if necessary. A foodItem object.

SetCookingMode directive example

{
  "directive": {
    "header": {
      "namespace": "Alexa.Cooking",
      "name": "SetCookingMode",
      "messageId": "<message id>",
      "correlationToken": "<an opaque correlation token>",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "<an OAuth2 bearer token>"
      },
      "endpointId": "<endpoint id>",
      "cookie": {}
    },
    "payload": {
      "cookingMode": {
        "value": "DEFROST"
      },
      "foodItem": {
        "foodName": "meat",
        "foodCategory": "BEEF",
        "foodQuantity": {
          "@type": "Weight",
          "value": "3",
          "unit": "POUND"
        }
      }
    }
  }
}

SetCookingMode response event

If you handle a SetCookingMode 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.

SetCookingMode response event example

The following example shows a response to a SetCookingMode directive. The context contains the values of all properties relevant to the current cooking action, even though some of the properties are defined by other interfaces.

{
  "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.Cooking",
        "name":"cookingMode",
        "value":"TIMECOOK",
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking",
        "name":"foodItem",
        "value":{
          "foodName":"Copper river salmon",
          "foodCategory":"FISH",
          "foodQuantity":{
            "@type":"Weight",
            "value":"2.5",
            "unit":"POUND"
          }
        },
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking",
        "name":"cookStartTime",
        "value":"2017-08-31T23:30:00Z",
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking",
        "name":"cookCompletionTime",
        "value":"2017-08-31T23:36:15Z",
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking",
        "name":"isCookCompletionTimeEstimated",
        "value":false,
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking.TimeController",
        "name":"requestedCookTime",
        "value":"PT6M15S",
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      },
      {
        "namespace":"Alexa.Cooking.TimeController",
        "name":"cookingPowerLevel",
        "value":{
          "@type":"EnumeratedPowerLevel",
          "value":"HIGH"
        },
        "timeOfSample":"2017-08-31T23:30:00Z",
        "uncertaintyInMilliseconds":0
      }
    ]
  }
}

SetCookingMode directive error handling

If you can't handle a SetCookingMode directive successfully, respond with an Alexa.Cooking.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 more information about state reports, see Understand State 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.Cooking",
         "name": "cookingMode",
         "value": "TIMECOOK",
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking",
         "name": "foodItem",
         "value":{
            "foodName": "Rice Pilaf",
            "foodCategory": "Rice",
            "foodQuantity":{
               "@type": "Volume",
               "value": "2",
               "unit": "US_FLUID_CUP"
            }
         },
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking",
         "name": "cookCompletionTime",
         "value": "2017-08-31T23:55Z",
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking",
         "name": "isCookCompletionTimeEstimated",
         "value": false,
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking",
         "name": "isHolding",
         "value": false,
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking.TimeController",
         "name": "requestedCookTime",
         "value": "PT25M",
         "timeOfSample": "2017-08-31T23:30:00Z",
         "uncertaintyInMilliseconds": 0
      },
      {
         "namespace": "Alexa.Cooking.TimeController",
         "name": "cookingPowerLevel",
         "value":{
            "@type": "EnumeratedPowerLevel",
            "value": "HIGH"
         },
         "timeOfSample": "2017-08-31T23:30: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 more information about change reports, see Understand State 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": "PHYSICAL_INTERACTION"
        },
        "properties": [
          {
             "namespace": "Alexa.Cooking",
             "name": "cookingMode",
             "value": "TIMECOOK",
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking",
             "name": "foodItem",
             "value":{
                "foodName": "Rice Pilaf",
                "foodCategory": "Rice",
                "foodQuantity":{
                   "@type": "Volume",
                   "value": "2",
                   "unit": "US_FLUID_CUP"
                }
             },
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking",
             "name": "cookCompletionTime",
             "value": "2017-08-31T23:55Z",
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking",
             "name": "isCookCompletionTimeEstimated",
             "value": false,
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking",
             "name": "isHolding",
             "value": true,
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking.TimeController",
             "name": "requestedCookTime",
             "value": "PT25M",
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          },
          {
             "namespace": "Alexa.Cooking.TimeController",
             "name": "cookingPowerLevel",
             "value":{
                "@type": "EnumeratedPowerLevel",
                "value": "HIGH"
             },
             "timeOfSample": "2017-08-31T23:30:00Z",
             "uncertaintyInMilliseconds": 0
          }
        ]
      }
    }
  },
  "context": {}
}