Reconfiguring skills to handle NLU evaluations
In your environment, if your skills are not yet performing NLU evaluations at the skill level or your skills are using the older skill-sdk
, you must take some action.
Tip: At each release of Watson Assistant Solutions, upgrade to the latest version of the NodeJS SDK to avail of its latest capabilities.
All skills registered with Watson Assistant Solutions must meet the following requirements:
- Use version 0.0.9 or later of the npm packaged NodeJS SDK
skill-sdk-nodejs
. - Handle NLU evaluations at the skill level.
Scenarios
Determine which of the following scenarios matches your environment and follow the appropriate procedures:
Scenario 1: Your skill does not include skill-sdk-nodejs
Complete these high-level steps:
- Include the SDK
skill-sdk-nodejs
in your skill. - Upgrade to the latest version of the
skill-sdk-nodejs
SDK.
Scenario 2: Your skill includes skill-sdk-nodejs
and is performing evaluations at the skill level
Complete this high-level step:
- Upgrade to the latest version of the
skill-sdk-nodejs
SDK.
Scenario 3: Your skill includes skill-sdk-nodejs
and is not performing evaluations at this skill level
Follow either option:
Option a: Modify the NLU configuration. Complete these high-level steps:
- Modify the NLU configuration of your skill.
- Upgrade to the latest version of the
skill-sdk-nodejs
SDK.
Option b: Migrate to the latest version of the skill boilerplate. Complete these high-level steps:
- Migrate to the latest version of the skill boilerplate.
- Upgrade to the latest version of the
skill-sdk-nodejs
SDK.
Scenario 4: You are using the skill REST interaces with other programming languages
If you used other programming languages to create your skills and not the NodeJS skill boilerplate, complete this high-level step:
- Add support for the evaluation method to your skill
Procedures
Complete the relevant procedures to meet the requirements of Watson Assistant Solutions.
Including the skill-sdk-nodejs
SDK in your skill (Scenario 1)
If your skill does not include the skill-sdk-nodejs
SDK, you must include it in the configuration of your skill. Complete these steps:
- Move the
manifest.json
file to theres/assets
directory of your skill. - Remove the
name
property from themanifest.json
file. - Open the
manifest.json
file and add the valueskill
to the NLU parameter. Valid values are:"nlu": [ "skill", "wcs", "regexp" ], "nlu": [ "skill", "wcs" ], "nlu": [ "skill", "regexp" ],
-
Include the
skill-sdk-nodejs
SDK. In theactions.js
file, at line 9, change the line:const {handler} = require('./skill-sdk');
to
const {handler} = require('skill-sdk-nodejs');
-
Replace the index.js file with the index file from the latest skill boilerplate.
- Remove the existing
skill-sdk
folder from your skill. - Add
"skill-sdk-nodejs":"0.0.x"
to the "dependencies" section of yourpackage.json
file. - Upgrade to the latest version of the
skill-sdk-nodejs
SDK.- Upgrade the NodeJS SDK. From the new skill directory, enter:
npm install
- Deploy your skill.
- If your skill includes the Watson Assistant (formerly Watson Conversation Services) nlu:
- Register your skill again with Watson Assistant Solutions. Use the
PUT /v2/api/skills/{skillName}
Watson Assistant Solutions conversation API. Specify the name and URL only. - Refresh your configuration of your skill. Use the
PUT /v2/api/skills/{skillName}/refresh
Watson Assistant Solutions conversation API. - Test your skill.
- Register your skill again with Watson Assistant Solutions. Use the
- Upgrade the NodeJS SDK. From the new skill directory, enter:
Upgrading the NodeJS SDK of your skill (Scenario 2)
To upgrade to the latest version of the skill NodeJS SDK, complete these steps:
- Upgrade the NodeJS SDK. From the new skill directory, enter:
npm install
- Deploy your skill.
- If your skill includes the Watson Assistant (formerly Watson Conversation Services) nlu:
- Register your skill again with Watson Assistant Solutions. Use the
PUT /v2/api/skills/{skillName}
Watson Assistant Solutions conversation API. Specify the skill name and URL only. - Refresh your configuration of your skill. Use the
PUT /v2/api/skills/{skillName}/refresh
Watson Assistant Solutions conversation API. - Test your skill.
- Register your skill again with Watson Assistant Solutions. Use the
Modifying the NLU configuration of your skill (Scenario 3, option a)
If your skill does not list the value skill
in the NLU parameter of the manifest.json
file, you must add it.
- Edit the
manifest.json
file and add the valueskill
to the NLU parameter. Valid values are:"nlu": [ "skill", "wcs", "regexp" ], "nlu": [ "skill", "wcs" ], "nlu": [ "skill", "regexp" ],
- Upgrade to the latest version of the
skill-sdk-nodejs
SDK- Upgrade the NodeJS SDK. From the new skill directory, enter:
npm install
- Deploy your skill.
- If your skill includes the Watson Assistant (formerly Watson Conversation Services) nlu:
- Register your skill again with Watson Assistant Solutions. Use the
PUT /v2/api/skills/{skillName}
Watson Assistant Solutions conversation API. Specify the skill name and URL only. - Refresh your configuration of your skill. Use the
PUT /v2/api/skills/{skillName}/refresh
Watson Assistant Solutions conversation API. - Test your skill.
- Register your skill again with Watson Assistant Solutions. Use the
- Upgrade the NodeJS SDK. From the new skill directory, enter:
Migrating to the latest version of the skill boilerplate (Scenario 3, option b)
To migrate to the latest version of the skill boilerplate, complete these steps:
- Clone the latest version of the skill boilerplate.
- Copy the
manifest.json
file from the oldexpertise/skill
directory to theres/assets
directory of your new skill. -
Open the
manifest.json
file and add the valueskill
to the NLU parameter. Valid values are:"nlu": [ "skill", "wcs", "regexp" ], "nlu": [ "skill", "wcs" ], "nlu": [ "skill", "regexp" ],
-
If you are using the regexp NLU,
- Copy your existing regexp NLU definition,
regexp.json
, tores/nlu/regexp.json
. - Copy your existing intents file,
intents.json
, tores/nlu/intents.json
.
- Copy your existing regexp NLU definition,
- If you are using a Watson Assistant (formerly Watson Conversation Service) NLU, edit the
res/nlu/wcs.json
file in the new version of the skill. Include the WCS credentials you specified when you previously registered the skill Watson Assistant Solutions. - Copy the contents from the
action.js
file to theaction.js
in the new version of your skill.- Copy your existing intents from the
createActionsHandler
function to the newaction.js
file. - If you used the deprecated method of calling WCS, replace with the new
handler.converse
or reuse the evaluation results. - Copy your existing code from the
unhandled
function to the newaction.js
file. - Use the
converseCallback
and theevaluationCallback
functions, as appropriate. - Copy any other functions to the new
action.js
file. - Copy the languageResource from the start of the file to new the
action.js
file.
- Copy your existing intents from the
- If your existing skill has a
manifest.yml
file, copy the file to the new version of your skill. - Update the
package.json
file.- Copy the name, description, version, and author from your existing skill to the new version of your skill.
- Copy any packages that require bespoke code to the new version of your skill.
- Upgrade to the latest version of the
skill-sdk-nodejs
SDK- Upgrade the NodeJS SDK. From the new skill directory, enter:
npm install
- Deploy your skill.
- If your skill includes the Watson Assistant (formerly Watson Conversation Services) nlu:
- Register your skill again with Watson Assistant Solutions. Use the
PUT /v2/api/skills/{skillName}
Watson Assistant Solutions conversation API. Specify the skill name and URL only. - Refresh your configuration of your skill. Use the
PUT /v2/api/skills/{skillName}/refresh
Watson Assistant Solutions conversation API.
- Register your skill again with Watson Assistant Solutions. Use the
- Test your skill.
- Upgrade the NodeJS SDK. From the new skill directory, enter:
Adding support for the evaluation method to your skill (Scenario 4)
If you used other programming languages to create your skills, add support for the evaluation method to your skill.
-
Add evaluate endpoints with a similar format to the following evaluation request and response JSONS. Evaluation request example:
{ "id": "001", "version": "1.0", "language": "en-US", "text": "Hello", "context": { "user": { "id": "user-001" }, "session": { "id": "string", "new": true, "attributes": {}, "version": "1.0" }, "application": { "id": "app-001", "attributes": {} } } }
Evaluation response example:
{ "intentities": [ { "intents": [ { "intent": "hello-world", "confidence": 1 } ], "name": "regexp", "entities": [] } ], "responseCode": 200, "handleUtterance": true, "requestResult": "Nlu engine did not return an output", "context": { "application": { "id": "app-001", "attributes": {} }, "session": { "attributes": {}, "skill": { "attributes": {} } } } }
- Verify that the manifest file of the skill matches the sample file provided in the NodeJS skill boilerplate.