-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bogdan Alexandru Militaru
authored and
Bogdan Alexandru Militaru
committed
Jan 22, 2019
0 parents
commit 0f7cded
Showing
33 changed files
with
5,073 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"deploy_settings": { | ||
"default": { | ||
"skill_id": "", | ||
"was_cloned": false, | ||
"merge": {} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# NPM dependencies | ||
node_modules | ||
|
||
# build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Starter-Pack-Alexa-Skill | ||
This is a Starter Pack skill for Amazon Alexa | ||
|
||
|
||
# Deployment | ||
|
||
**ASK CLI** will create the skill and the Lambda function for you. | ||
```bash | ||
$ ask deploy | ||
``` | ||
|
||
# Local development | ||
|
||
In order to develop locally and see your changes reflected instantly, you will need to create an SSH tunnel or expose somehow your local development server. There are several services that allow you to do this, for example [ngrok](https://ngrok.com/) or [serveo.net](https://serveo.net/). | ||
|
||
## Using servo.net | ||
|
||
|
||
1. You need to have an SSH client installed, then simply run | ||
|
||
```bash | ||
$ ssh -R 80:localhost:3000 serveo.net | ||
Forwarding HTTP traffic from [https://YOUR_URL] | ||
Press g to start a GUI session and ctrl-c to quit. | ||
``` | ||
|
||
2. Once you see the URL, copy it and go to your Skill console. | ||
|
||
3. Open the `Endpoint` menu and select `HTTPS` | ||
|
||
4. Under `Default Region` paste the previous URL you copied. | ||
|
||
5. On the select box choose: `My development endpoint is a sub-domain of a domain that has a wildcard certificate from a certificate authority`. | ||
|
||
6. Run `npm start` to start the local server and begin testing the skill. | ||
|
||
That's it. | ||
|
||
## Using [ngrok](https://ngrok.com/download) | ||
|
||
1. Install [ngrok](https://ngrok.com/download) | ||
|
||
2. Run `ngrok http 3000` | ||
|
||
3. Copy the URL and follow the same steps above from 3 to 6. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
require("@babel/register")({ | ||
rootMode: "upward", | ||
babelrcRoots: [ | ||
".", | ||
"packages/*", | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Powershell script for ask-cli post-new hook for Node.js | ||
# Script Usage: post_new_hook.ps1 <SKILL_NAME> <DO_DEBUG> <TARGET> | ||
|
||
# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters. | ||
# DO_DEBUG is boolean value for debug logging | ||
|
||
# Run this script one level outside of the skill root folder | ||
|
||
# The script does the following: | ||
# - Run "npm install" in each sourceDir in skill.json | ||
|
||
param( | ||
[string] $SKILL_NAME, | ||
[bool] $DO_DEBUG = $False | ||
) | ||
|
||
if ($DO_DEBUG) { | ||
Write-Output "###########################" | ||
Write-Output "###### post-new hook ######" | ||
Write-Output "###########################" | ||
} | ||
|
||
function install_dependencies ($CWD, $SOURCE_DIR) { | ||
$INSTALL_PATH = $SKILL_NAME + "\" +$SOURCE_DIR | ||
Set-Location $INSTALL_PATH | ||
Invoke-Expression "npm install" 2>&1 | Out-Null | ||
$EXEC_RESULT = $? | ||
Set-Location $CWD | ||
return $EXEC_RESULT | ||
} | ||
|
||
$SKILL_FILE_PATH = $SKILL_NAME + "\skill.json" | ||
$ALL_SOURCE_DIRS = Get-Content -Path $SKILL_FILE_PATH | select-string -Pattern "sourceDir" -CaseSensitive | ||
Foreach ($SOURCE_DIR in $ALL_SOURCE_DIRS) { | ||
$FILTER_SOURCE_DIR = $SOURCE_DIR -replace "`"", "" -replace "\s", "" -replace ",","" -replace "sourceDir:", "" | ||
$CWD = (Get-Location).Path | ||
if (install_dependencies $CWD $FILTER_SOURCE_DIR) { | ||
if ($DO_DEBUG) { | ||
Write-Output "Codebase ($FILTER_SOURCE_DIR) built successfully." | ||
} | ||
} else { | ||
if ($DO_DEBUG) { | ||
Write-Output "There was a problem installing dependencies for ($FILTER_SOURCE_DIR)." | ||
} | ||
exit 1 | ||
} | ||
} | ||
|
||
if ($DO_DEBUG) { | ||
Write-Output "###########################" | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
# Shell script for ask-cli post-new hook for Node.js | ||
# Script Usage: post_new_hook.sh <SKILL_NAME> <DO_DEBUG> <TARGET> | ||
|
||
# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters. | ||
# DO_DEBUG is boolean value for debug logging | ||
|
||
# Run this script one level outside of the skill root folder | ||
|
||
# The script does the following: | ||
# - Run "npm install" in each sourceDir in skill.json | ||
|
||
SKILL_NAME=$1 | ||
DO_DEBUG=${2:-false} | ||
|
||
if [ $DO_DEBUG == false ] | ||
then | ||
exec > /dev/null 2>&1 | ||
fi | ||
|
||
install_dependencies() { | ||
npm install --prefix "$SKILL_NAME/$1" >/dev/null 2>&1 | ||
return $? | ||
} | ||
|
||
echo "###########################" | ||
echo "###### post-new hook ######" | ||
echo "###########################" | ||
|
||
grep "sourceDir" $SKILL_NAME/skill.json | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | while read -r SOURCE_DIR; do | ||
if install_dependencies $SOURCE_DIR; then | ||
echo "Codebase ($SOURCE_DIR) built successfully." | ||
else | ||
echo "There was a problem installing dependencies for ($SOURCE_DIR)." | ||
exit 1 | ||
fi | ||
done | ||
echo "###########################" | ||
|
||
exit 0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Powershell script for ask-cli pre-deploy hook for Node.js | ||
# Script Usage: pre_deploy_hook.ps1 <SKILL_NAME> <DO_DEBUG> <TARGET> | ||
|
||
# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters. | ||
# DO_DEBUG is boolean value for debug logging | ||
# TARGET is the deploy TARGET provided to the CLI. (eg: all, skill, lambda etc.) | ||
|
||
# Run this script under the skill root folder | ||
|
||
# The script does the following: | ||
# - Run "npm install" in each sourceDir in skill.json | ||
|
||
param( | ||
[string] $SKILL_NAME, | ||
[bool] $DO_DEBUG = $False, | ||
[string] $TARGET = "all" | ||
) | ||
|
||
function install_dependencies ($CWD, $SOURCE_DIR) { | ||
Set-Location $SOURCE_DIR | ||
Invoke-Expression "npm install" 2>&1 | Out-Null | ||
$EXEC_RESULT = $? | ||
Set-Location $CWD | ||
return $EXEC_RESULT | ||
} | ||
|
||
if ($DO_DEBUG) { | ||
Write-Output "###########################" | ||
Write-Output "##### pre-deploy hook #####" | ||
Write-Output "###########################" | ||
} | ||
|
||
if ($TARGET -eq "all" -Or $TARGET -eq "lambda") { | ||
$ALL_SOURCE_DIRS = Get-Content -Path "skill.json" | select-string -Pattern "sourceDir" -CaseSensitive | ||
Foreach ($SOURCE_DIR in $ALL_SOURCE_DIRS) { | ||
$FILTER_SOURCE_DIR = $SOURCE_DIR -replace "`"", "" -replace "\s", "" -replace ",","" -replace "sourceDir:", "" | ||
$CWD = (Get-Location).Path | ||
if (install_dependencies $CWD $FILTER_SOURCE_DIR) { | ||
if ($DO_DEBUG) { | ||
Write-Output "Codebase ($FILTER_SOURCE_DIR) built successfully." | ||
} | ||
} else { | ||
if ($DO_DEBUG) { | ||
Write-Output "There was a problem installing dependencies for ($FILTER_SOURCE_DIR)." | ||
} | ||
exit 1 | ||
} | ||
} | ||
if ($DO_DEBUG) { | ||
Write-Output "###########################" | ||
} | ||
} | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
# Shell script for ask-cli pre-deploy hook for Node.js | ||
# Script Usage: pre_deploy_hook.sh <SKILL_NAME> <DO_DEBUG> <TARGET> | ||
|
||
# SKILL_NAME is the preformatted name passed from the CLI, after removing special characters. | ||
# DO_DEBUG is boolean value for debug logging | ||
# TARGET is the deploy TARGET provided to the CLI. (eg: all, skill, lambda etc.) | ||
|
||
# Run this script under skill root folder | ||
|
||
# The script does the following: | ||
# - Run "npm install" in each sourceDir in skill.json | ||
|
||
SKILL_NAME=$1 | ||
DO_DEBUG=${2:-false} | ||
TARGET=${3:-"all"} | ||
|
||
if [ $DO_DEBUG == false ] | ||
then | ||
exec > /dev/null 2>&1 | ||
fi | ||
|
||
install_dependencies() { | ||
npm install --prefix "$1" >/dev/null 2>&1 | ||
return $? | ||
} | ||
|
||
echo "###########################" | ||
echo "##### pre-deploy hook #####" | ||
echo "###########################" | ||
|
||
if [[ $TARGET == "all" || $TARGET == "lambda" ]]; then | ||
grep "sourceDir" ./skill.json | cut -d: -f2 | sed 's/"//g' | sed 's/,//g' | while read -r SOURCE_DIR; do | ||
if install_dependencies $SOURCE_DIR; then | ||
echo "Codebase ($SOURCE_DIR) built successfully." | ||
else | ||
echo "There was a problem installing dependencies for ($SOURCE_DIR)." | ||
exit 1 | ||
fi | ||
done | ||
echo "###########################" | ||
fi | ||
|
||
exit 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"@babel/preset-env" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './unknown' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const Unknown = { | ||
canHandle() { | ||
return true; | ||
}, | ||
handle(handler, error) { | ||
console.log(error); | ||
|
||
const { t } = handler.attributesManager.getRequestAttributes(); | ||
const speechText = t('UNKNOWN_ERROR'); | ||
|
||
return handler.responseBuilder | ||
.speak(speechText) | ||
.reprompt(speechText) | ||
.getResponse(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import * as Alexa from "ask-sdk-core"; | ||
import * as Intents from './intents' | ||
import * as Interceptors from './interceptors' | ||
import * as Errors from './errors' | ||
|
||
export const handler = Alexa.SkillBuilders.custom() | ||
.addRequestHandlers( | ||
// Intents.Debug, | ||
|
||
// Built-In Intents | ||
Intents.Launch, | ||
Intents.Help, | ||
Intents.Stop, | ||
Intents.Cancel, | ||
Intents.Fallback, | ||
|
||
) | ||
.addErrorHandlers( | ||
Errors.Unknown, | ||
) | ||
.addRequestInterceptors( | ||
Interceptors.LocalizationInterceptor, | ||
).addResponseInterceptors( | ||
).lambda(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
import { IsIntentType } from '../helpers'; | ||
|
||
export const Cancel = { | ||
canHandle(handler) { | ||
return IsIntentType(handler, 'AMAZON.CancelIntent') | ||
}, | ||
handle(handler) { | ||
const { t } = handler.attributesManager.getRequestAttributes(); | ||
const speechText = t("GOODBYE"); | ||
|
||
return handler.responseBuilder | ||
.speak(speechText) | ||
.reprompt(speechText) | ||
.withShouldEndSession(true) | ||
.getResponse(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
import { IsIntentType } from '../helpers'; | ||
|
||
export const Fallback = { | ||
canHandle(handler) { | ||
return IsIntentType(handler, 'AMAZON.FallbackIntent') | ||
}, | ||
handle(handler) { | ||
const { t } = handler.attributesManager.getRequestAttributes(); | ||
|
||
return handler.responseBuilder | ||
.speak(t("INCOMPREHENSIBLE")) | ||
.reprompt(t("INCOMPREHENSIBLE_REPROMT")) | ||
.getResponse(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
import { IsIntentType } from '../helpers'; | ||
|
||
export const Help = { | ||
canHandle(handler) { | ||
return IsIntentType(handler, 'AMAZON.HelpIntent') | ||
}, | ||
handle(handler) { | ||
const { t } = handler.attributesManager.getRequestAttributes(); | ||
const speechText = t("HELP"); | ||
|
||
return handler.responseBuilder | ||
.speak(speechText) | ||
.reprompt(speechText) | ||
.getResponse(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './launch' | ||
export * from './help' | ||
export * from './stop' | ||
export * from './cancel' | ||
export * from './fallback' |
Oops, something went wrong.