Giter Club home page Giter Club logo

alexa2directlinebot's Introduction

Alexa2DirectLineBot

A sample that connects Microsoft Bot Framework to Alexa Skill via the Bot Framework Direct Line connector client.

Based on Stefan Negritoiu (FreeBusy) Alexaskills.net Speechlet project. See License file for details.

There is an alternative NodeJS Alexa Bridge published here (https://github.com/CatalystCode/alexa-bridge). You will still need to use the custom slot approach documented here to prevent truncation of the received utterance.

Modified very simply with the Direct Line client for the Microsoft Bot Connector.

There are two approaches to using Direct Line.

  • 1) Use the Alexa skill to deliver its utterance as heard to the Bot Framework bot.
  • 2) Use the Alexa skill to determine intents and custom slot types to match bot framework bot's LUIS intents and entity lists.

    With the first option there are serious limitations.

  • The Alexa skill has a limited word count it can receive
  • It appears that Alexa's speech recognition ability is reduced without a focused vocabulary. Your mileage will vary.
  • Alexa session is closed after each interaction. Retaining the session is to be tested.
  • This isn't an Amazon recognised technique. I have shared my approach with Amazon and hope they will support it. Collaboration is the way forward to a better world :-)

    With the second option you have to duplicate your NLP model in both LUIS and Alexa. An automated transformation from LUIS to Alexa JSON should be possible - watch this space.

    Build your bot with Microsoft Bot Framework.

    (https://docs.microsoft.com/en-us/bot-framework/bot-builder-overview-getstarted)

    Publish your bot (https://docs.microsoft.com/en-us/bot-framework/portal-register-bot) and enable a Direct Line channel via the Bot Connector (https://docs.microsoft.com/en-us/bot-framework/channel-connect-directline).

    Alexa Skill definition - using utterance approach 1)

    A generic Alexa skill definition is published via the Amazon developer Alexa Skills site (http://developer.Amazon.com).

    Interaction Model

    Intent Schema

    {
     "intents": [
       {
         "slots": [
           {
             "name": "phrase",
             "type": "phrase"
           }
         ],
         "intent": "GetUserIntent"
       }
     ]
    }
    

    Custom Slot Type: phrase

    blah
    blah blah
    blah blah blah
    blah blah blah blah
    blah blah blah blah blah
    blah blah blah blah blah blah
    blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
    

    Note: an utterance is required for the utterance word count you expect to receive. If you receive a truncated GetUserIntent utterance from the skill you need to increase entries here. Above delivers 1 to 20 words utterance output.

    Sample Utterances

    GetUserIntent {phrase}
    

    Alexa skill definition - utternace approach 2)

    Define your Alexa skill with intent names matching the bot's LUIS intents. And create custom slot definitions to match the LUIS entity lists.

    Both Alexa skill approaches can be completed using the following configurations.

    Endpoint configuration.

    Service Endpoint type:

    https
    

    Default:

    https://yourwebappapi.azurewebsites.net/
    

    Azure web app service Alexa Skill Kit .Net implementation.

    Clone this repro to build your basic ASP.net web api service.

    Edit SampleSessionSpeechlet.cs to change the values for the direct line details to your bot.

            private static string directLineSecret = "<your secret here>";
            private static string botId = "<your bot text id here>";
    

    Edit OnRequestValidation to test for your Alexa Skill application id.

                if (requestEnvelope?.Session?.Application?.Id?.Equals("<your Alexa skill application id") == false)
    

    Now edit your OnIntent method to deliver the Alexa card format you want and the skill option required.

  • 1) Utterance passing
    // Utterance pass through use this line
    string utterance = request.Intent.Slots["phrase"].Value;
    
  • 2) Alexa determined intent and slot value
    // Where using Alexa Intent and Slot definitions use this
    string utterance = String.Format("{0} {1}", intentName, request.Intent.Slots["<your slot type>"].Value);
    

    Multiple slot type handling is left as a task to do.

    Testing

    Once the web api service is published you can test your Alexa skill from the test page of your Alexa skill definition Service Simulator.

    To Do:

  • Implement Bot Framework hero cards into Alexa Skill cards
  • alexa2directlinebot's People

    Contributors

    pauldfoster avatar

    Stargazers

     avatar  avatar  avatar

    Watchers

     avatar  avatar

    alexa2directlinebot's Issues

    Recommend Projects

    • React photo React

      A declarative, efficient, and flexible JavaScript library for building user interfaces.

    • Vue.js photo Vue.js

      ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

    • Typescript photo Typescript

      TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    • TensorFlow photo TensorFlow

      An Open Source Machine Learning Framework for Everyone

    • Django photo Django

      The Web framework for perfectionists with deadlines.

    • D3 photo D3

      Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

    Recommend Topics

    • javascript

      JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

    • web

      Some thing interesting about web. New door for the world.

    • server

      A server is a program made to process requests and deliver data to clients.

    • Machine learning

      Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

    • Game

      Some thing interesting about game, make everyone happy.

    Recommend Org

    • Facebook photo Facebook

      We are working to build community through open source technology. NB: members must have two-factor auth.

    • Microsoft photo Microsoft

      Open source projects and samples from Microsoft.

    • Google photo Google

      Google โค๏ธ Open Source for everyone.

    • D3 photo D3

      Data-Driven Documents codes.