Git Product home page Git Product logo

alexarb's Introduction

alexarb - Ruby wrapper to handle Amazon Alexa custom skills requests.

Handle alexa custom skill request and responses. Amazon provides some helpers to develop Alexa skills whereas the main focus is on JavaScript. If you have a ruby based application and you want keep a skill close to it, this library might help you.

Happy to help, feel free to open an issue on any question.

Usage

# Build a handler that takes a rack request and returns a proper response.
class AlexaHandler < Alexarb::Application
  attr_accessor :user

  before_filter do
    self.user ||= User.find_or_create_by ask_id: jeff.whoami
    Rails.logger.debug "[AlexaHandler] RECEIVED #{request.raw}"
  end

  after_filter do
    Rails.logger.debug "[AlexaHandler] ANSWER #{response.to_h}"
  end

  launch_request do
    alexa.say 'hello'
  end

  intent 'AMAZON.HelpIntent' do
    alexa.say 'what?'
  end

  intent 'CustomIntent' do
    MyCustomIntentHandler.new(request, user).update alexa
  end
end

# Register a Handler in config/routes.rb on any route.
Rails.application.routes.draw do
  # ...
  mount AlexaHandler => '/alexa'
end

# or in a rack environment
AlexaHandler.call env
# or on a custom environment
AlexaHandler.new(request, response).call


# Without request handler, read a request received using...
request = Alexarb::Request.new request.body.read
request.intent

Development

$ gem install minitest
$ rake test # run tests

References

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.