Implement CanFulfillIntentRequest for Name-free Interactions

To increase discoverability of your skill through name-free interaction, consider implementing the CanFulfillIntentRequest interface in your skill. By doing so, you increase the likelihood that your skill is selected when a customer who may not even have enabled your skill makes a request, question, or statement.

See also:

 

Update the SDK used by your skill if applicable

If you have used the ASK SDK for Node.js or the ASK SDK for Java in your skill development, and you want to add support for the CanFulfillIntentRequest interface to your Alexa skill, you must update to the ASK SDK v2 for Node.js (Public beta) or ASK SDK v2 for Java (Public beta), as appropriate.

These steps may now be completed through ASK CLI, or through the developer console.

Implement CanFulfillIntentRequest with ASK CLI

To set up ASK CLI, see Quick Start Alexa Skills Kit Command Line Interface. Create a new skill if desired.

If you have set up ASK CLI and are now updating an existing skill, obtain the skill manifest file with this command:

$ ask api get-skill --skill-id amzn1.ask.skill.[unique-value-here] > skill.json

To add support to your skill for CanFulfillIntentRequest, edit the skill.json file, which contains the skill manifest.

Edit the skill information file to include "CAN_FULFILL_INTENT_REQUEST" as a new interface type entry. In the following sample manifest, refer to the interfaces values. Thus, "CAN_FULFILL_INTENT_REQUEST" is another interface which you as a skill developer can choose to support or not.

{
  "manifest":{
    "manifestVersion":"1.0",
    "publishingInformation":{
      "locales":{
        "en-US":{
          "name":"MySkill",
          "summary":"Sample Short Description",
          "description":"Sample Full Description",
          "examplePhrases": [
            "Alexa open hello world",
            "Alexa tell hello world I am Jeff",
            "Alexa tell hello world my name is Peter"
          ]
        }
      },
      "distributionCountries":[
        "US"
      ],
      "isAvailableWorldwide":false,
      "testingInstructions":"Sample Testing Instructions",
      "category":"EDUCATION_AND_REFERENCE"
    },
    "apis":{
      "custom":{
        "endpoint":{
          "uri":"https://customapi-eu.example.com",
          "sslCertificateType":"TRUSTED"
        },
        "regions":{
          "NA":{
            "endpoint":{
              "uri":"https://customapi-na.example.com",
              "sslCertificateType":"TRUSTED"
            }
          }
        },
        "interfaces":[
          {
            "type":"VIDEO_APP"
          },
          {
            "type":"RENDER_TEMPLATE"
          },
          {
            "type":"AUDIO_PLAYER"
          },
          {
            "type":"CAN_FULFILL_INTENT_REQUEST"
          }
        ]
      }
    }
  }
}

Update or create your skill in ASK CLI

You can now use the command-line interface to update or create the new skill definition.

If you are updating an existing skill, use:

$ ask api update-skill --skill-id amzn1.ask.skill.[unique-value-here] --file /path/to/skill/information/file

If you are creating a new skill, use:

$ ask api create-skill --file /path/to/skill/information/file

Implement CanFulfillIntentRequest through the developer console

Open your skill in the developer console. Go to the Build > Custom > Interfaces page, and enable the CanFulfillIntentRequest interface.

Select the CanFulfillIntentRequest interface
Select the CanFulfillIntentRequest interface

Scroll to the top of the panel, and then click Save Interfaces. In the bottom right, a message should appear indicating that the skill manifest saved successfully.

Click 'Save Interfaces' button
Click 'Save Interfaces' button

Add logic in your skill service to fulfill responses to CanFulfillIntentRequest

Whether you have implemented CanFulfillIntentRequest with ASK CLI or through the developer console, the steps to implement the logic in your skill are the same.

See Understand Name-free Interaction for Custom Skills.

Invoke and test the skill

After you've updated your skill manifest and updated the code for your skill service, you can invoke the skill from ASK CLI or the developer console to test your skill's response.

Create the JSON for testing your skill

Create a new .json file containing the input JSON with the request type set to CanFulfillIntentRequest.

The following is a sample .json file for the request. Substitute the appropriate values for your skill. Because you cannot test CanFulfillIntentRequest with an Alexa-enabled device, the purpose of this file is to duplicate the content of an actual CanfulfillIntentRequest from Alexa for testing with ASK CLI, or in the Alexa Simulator, as described in the next section.

{
  "session":{
    "new": true,
    "sessionId":"SessionId.[unique-value-here]",
    "application":{
      "applicationId":"amzn1.ask.skill.[unique-value-here]"
    },
    "attributes":{
      "key": "string value"
    },
    "user":{
      "userId":"amzn1.ask.account.[unique-value-here]"
    }
  },
  "request":{
    "type":"CanFulfillIntentRequest",
    "requestId":"EdwRequestId.[unique-value-here]",
    "intent":{
      "name":"MyNameIsIntent",
      "slots":{
        "name":{
          "name":"name",
          "value":"Jeff"
        }
      }
    },
    "locale":"en-US",
    "timestamp":"2017-10-03T22:02:29Z"
  },
  "context":{
    "AudioPlayer":{
      "playerActivity":"IDLE"
    },
    "System":{
      "application":{
        "applicationId":"amzn1.ask.skill.[unique-value-here]"
      },
      "user":{
        "userId":"amzn1.ask.account.[unique-value-here]"
      },
      "device":{
        "supportedInterfaces":{

        }
      }
    }
  },
  "version":"1.0"
}

Prepare and test your skill for certification

Whether you are testing in ASK CLI or in the developer console, make sure to test across the following scenarios:

  • Verify that your skill handles a CanFulfillIntentRequest call with no userId present.
  • Verify that your skill handles a CanFulfillIntentRequest call with no session information present.
  • Verify that your skill handles a CanFulfillIntentRequest call for every intent included in your interaction model.

Test the skill using ASK CLI

To invoke the skill from ASK CLI, use the following command:

$ ask api invoke-skill --skill-id amzn1.ask.skill.[unique-value-here] --file /path/to/input/json --endpoint-region [endpoint-region-here]

This command writes your skill's response to the CanFulfillIntentRequest to standard output. In order to properly test your skill's response, the .json file you created must match the CanFulfillIntentRequest that Alexa would send to your skill.

Test the skill using the developer console

  1. In the developer console, click the Test tab.
  2. Click Manual JSON.
  3. In the text box, enter the JSON for a CanFulfillIntentRequest that invokes the endpoint for your skill.
Manual JSON
Manual JSON

For aa sample .json file, see create the JSON for testing your skill.