alexa_skillsimulator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/lib/alexa_skillsimulator.rb +118 -0
- data.tar.gz.sig +0 -0
- metadata +86 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 92f8afa4b48177f0c1e299c891f29ce9af26e196
|
4
|
+
data.tar.gz: c05465e54982168584b67333d67c78110f47b74a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b0ba1262c8a565f0255b611dc33eb65f6e4b5983086fd208036a926533eb41185cd4c0e214bffd97f89c2bc7f5b43cd0cbf77149e01017b4fdfd8f18352e177e
|
7
|
+
data.tar.gz: a039b70f71a2f39ec4e02ba5f3a294d8a9aa18eced01e653aa4bffa016f44b8c0d93468fc4c16e1ef64805dc2f14975c7edbd36c67ae3166e7dd192fabcc7337
|
checksums.yaml.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: alexa_skillsimulator.rb
|
4
|
+
|
5
|
+
require 'time'
|
6
|
+
require 'rest-client'
|
7
|
+
require 'securerandom'
|
8
|
+
|
9
|
+
|
10
|
+
class AlexaSkillSimulator
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(manifest, model, debug: false)
|
14
|
+
|
15
|
+
@debug = debug
|
16
|
+
|
17
|
+
# get the utterances
|
18
|
+
|
19
|
+
@utterances = model['interactionModel']['languageModel']\
|
20
|
+
['intents'].inject({}) do |r, intent|
|
21
|
+
intent['samples'].each {|x| r[x] = intent['name']}
|
22
|
+
r
|
23
|
+
end
|
24
|
+
|
25
|
+
puts ' debugger::@utterances: ' + @utterances.inspect if @debug
|
26
|
+
|
27
|
+
# get the endpoint
|
28
|
+
@endpoint = manifest['manifest']['apis']['custom']['endpoint']['uri']
|
29
|
+
|
30
|
+
puts ' debugger: @endpoint: ' + @endpoint.inspect if @debug
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def start()
|
35
|
+
|
36
|
+
puts
|
37
|
+
puts 'Starting ... (to exit press CTRL-C)'
|
38
|
+
|
39
|
+
while true do
|
40
|
+
|
41
|
+
puts
|
42
|
+
puts 'Alexa is ready'
|
43
|
+
puts
|
44
|
+
print '> '
|
45
|
+
s = gets.downcase.chomp
|
46
|
+
puts
|
47
|
+
puts ' debugger: s: ' + s.inspect if @debug
|
48
|
+
|
49
|
+
r = @utterances[s]
|
50
|
+
puts ' debugger: r: ' + r.inspect if @debug
|
51
|
+
puts
|
52
|
+
|
53
|
+
if r then
|
54
|
+
|
55
|
+
puts ' debugger: your intent is to ' + r if @debug
|
56
|
+
|
57
|
+
response = respond()
|
58
|
+
puts "Alexa says: " + response
|
59
|
+
|
60
|
+
else
|
61
|
+
puts "Alexa says: I'm sorry I didn't understand what you said"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def post(url, h)
|
71
|
+
|
72
|
+
r = RestClient.post(url, h.to_json,
|
73
|
+
headers={content_type: :json, accept: :json})
|
74
|
+
JSON.parse r.body, symbolize_names: true
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
def respond(intent=nil)
|
79
|
+
|
80
|
+
h = {"version"=>"1.0",
|
81
|
+
"session"=>
|
82
|
+
{"new"=>true,
|
83
|
+
"sessionId"=>"amzn1.echo-api.session.1",
|
84
|
+
"application"=>
|
85
|
+
{"applicationId"=>"amzn1.ask.skill.0"},
|
86
|
+
"user"=>
|
87
|
+
{"userId"=>
|
88
|
+
"amzn1.ask.account.I"}},
|
89
|
+
"context"=>
|
90
|
+
{"System"=>
|
91
|
+
{"application"=>
|
92
|
+
{"applicationId"=>
|
93
|
+
"amzn1.ask.skill.0"},
|
94
|
+
"user"=>
|
95
|
+
{"userId"=>
|
96
|
+
"amzn1.ask.account.I"},
|
97
|
+
"device"=>
|
98
|
+
{"deviceId"=>
|
99
|
+
"amzn1.ask.device.A",
|
100
|
+
"supportedInterfaces"=>{}},
|
101
|
+
"apiEndpoint"=>"https://api.eu.amazonalexa.com",
|
102
|
+
"apiAccessToken"=>
|
103
|
+
"A"}},
|
104
|
+
"request"=>
|
105
|
+
{"type"=>"LaunchRequest",
|
106
|
+
"requestId"=>"amzn1.echo-api.request.a",
|
107
|
+
"timestamp"=> Time.now.utc.iso8601,
|
108
|
+
"locale"=>"en-US",
|
109
|
+
"shouldLinkResultBeReturned"=>false}}
|
110
|
+
|
111
|
+
r = post @endpoint, h
|
112
|
+
puts ' degbugger: r: ' + r.inspect if @debug
|
113
|
+
puts
|
114
|
+
|
115
|
+
r[:response][:outputSpeech][:text]
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alexa_skillsimulator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Robertson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwNzAyMTEyMzUyWhcN
|
15
|
+
MTkwNzAyMTEyMzUyWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQ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00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rest-client
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.0'
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.0.2
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - "~>"
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '2.0'
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.0.2
|
55
|
+
description:
|
56
|
+
email: james@jamesrobertson.eu
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- lib/alexa_skillsimulator.rb
|
62
|
+
homepage: https://github.com/jrobertson/alexa_skillsimulator
|
63
|
+
licenses:
|
64
|
+
- MIT
|
65
|
+
metadata: {}
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 2.6.13
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A local simulator for your Alexa Skill.
|
86
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|