From d8d56fdf0a8374c61e460bad9c661549be23068d Mon Sep 17 00:00:00 2001 From: Scott BonAmi Date: Wed, 21 Jun 2017 23:59:11 -0400 Subject: [PATCH] Bump README and CHANGELOG for new Dialogue logic --- CHANGELOG.md | 1 + README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b80f044..5ab1364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 4.0.2 (Next) * [#97](https://github.com/alexa-js/alexa-app/pull/97): Added support for custom directives - [@ajcrites](https://github.com/ajcrites). * [#248](https://github.com/alexa-js/alexa-app/pull/248): Add support for intent and slot `confirmationStatus` - [@sbonami]((https://github.com/sbonami). +* [#249](https://github.com/alexa-js/alexa-app/pull/249): Add support for handling and/or delegating Dialogue - [@sbonami]((https://github.com/sbonami). * Your contribution here ### 4.0.1 (May 17, 2017) diff --git a/README.md b/README.md index 29c82c7..fb21a97 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ * [Generating Schema and Utterances Output](#generating-schema-and-utterances-output) * [Cards](#cards) * [Card Examples](#card-examples) +* [Custom Directives](#custom-directives) +* [Dialogue](#dialogue) * [Error Handling](#error-handling) * [Asynchronous Handlers Example](#asynchronous-handlers-example) * [Customizing Default Error Messages](#customizing-default-error-messages) @@ -167,6 +169,9 @@ String request.confirmationStatus // check if the intent is confirmed Boolean request.isConfirmed() +// return the Dialogue object +Dialogue request.getDialogue() + // check if you can use session (read or write) Boolean request.hasSession() @@ -640,6 +645,43 @@ The `alexa-app` library has special handling for AudioPlayer directives, so you The `response.directive` adds your directive object to the directives array in the response. To clear the directives from the response, call `response.getDirectives().clear()`. +## Dialogue + +The `alexa-app` library has special handling for enabling Alexa to handle Dialogue directly. To +configure `alexa-app` to delegate dialogue to Alexa, enable the handling +per-intent via the schema: + +```javascript +app.intent("sampleIntent", { + "dialogue": { + type: "delegate" + }, + "slots": { ... }, + "utterances": [ ... ], + }, + function(request, response) { ... } +); +``` + +### dialogue object + +```javascript +// return the Dialogue object +Dialogue request.getDialogue() + +// return the intent's dialogueState +String request.dialogueState + +// check if the intent's dialogue is STARTED +Boolean dialogue.isStarted() + +// check if the intent's dialogue is IN_PROGRESS +Boolean dialogue.isInProgress() + +// check if the intent's dialogue is COMPLETED +Boolean dialogue.isCompleted() +``` + ## Error Handling When handler functions throw exceptions, they will trigger a rejection in the promise chain. If the response has not already been sent, `.post` will be triggered which will allow you to force a successful response. If `post` does not alter the response, then a failed response will be sent. You can use this to throw an exception to or call `return response.fail("message")` to force a failure, but this *does not* generate a response compatible with Alexa.