From 97667a38824f1a697ae5f36b6ea8167f0a36bf9d Mon Sep 17 00:00:00 2001 From: Dustin Coates Date: Mon, 5 Dec 2016 20:35:58 +0100 Subject: [PATCH] Add interface for adapter --- README.md | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 655b0cb..76c0e74 100644 --- a/README.md +++ b/README.md @@ -1 +1,46 @@ -# Algolia Alexa Skills Kit Adapter \ No newline at end of file +# Algolia Alexa Skills Kit Adapter + +This is an adapter that allows you to use the Algolia search API easily within your Alexa Skills Kit Skill. + +```javascript +let voiceSearch = algoliaAlexaAdapter({ + algoliaAppId: 'APP_ID', + alexaAppId: 'FROM_AMAZON_LAMBDA', + defaultIndexName: 'products', + comparisons: [{ + 'less than': '>', + 'greater than': '>' + }], + availableSorts: [{ + indexName: 'products_PRICE_DESC', + invocations: ['price descending', 'price low to high'] + }, { + indexName: 'products_PRICE_ASC', + invocations: ['price ascending', 'price high to low'] + }], + handlers: { + onLaunch: function(launchRequest, session, response) { + // + }, + intentHandlers: { + SearchProductIntent: { + speechTemplate: 'The top product is {{name}} from {{brand}}. It costs ${{price}}.', + emptyTemplate: function(data){ + return 'There were no products for your {{data.query}} search.' + }, + comparisons: { + 'more expensive than': '>', + 'less expensive than': '<' + }, + facets: ['brand', 'availability'] + }, + HelpIntent: function(intent, session, response){ + var speechOutput = 'Find one of 10,000 products from Best Buy, powered by Algolia.'; + response.ask(speechOutput); + } + } + } +}); + +exports.handler = voiceSearch.search(event, context); +```