A plug that validates Alexa requests (required during certification)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
test
.credo.exs
.gitignore
.travis.yml
LICENSE
NOTICE
README.md
mix.exs
mix.lock

README.md

LessVerifiesAlexa

Build Status Inline docs

This is a plug that validates requests from Amazon's Alexa service. Amazon requires that your skills validate requests during its certification process.

Installation

You can install less_verifies_alexa by adding it to your list of dependencies in mix.exs:

def deps do
  [{:less_verifies_alexa, "~> 0.1.0"}]
end

Usage

Add the plug to your router like this:

if Mix.env == :prod do # You don't want this to run in dev & test.
  plug LessVerifiesAlexa.Plug, application_id: "your_app_id"
end

In order for the plug to work, there's an additional change you have to make. In your endpoint.ex, you have to change your Parsers plug to use a custom JSON parser that this package provides.

Just change :json to :alexajson and you should end up with something like this:

plug Plug.Parsers,
  parsers: [:alexajson, :urlencoded, :multipart],
  pass: ["*/*"],
  json_decoder: Poison

You have to do this due to a Plug implementation detail we won't go into here. Hopefully, we'll soon be submitting a PR to plug itself that should remove the need for this custom adapter.

Documentation

Documentation can be generated with ExDoc and published on HexDocs. The docs can be found at https://hexdocs.pm/less_verifies_alexa.