test

package
v0.0.0-...-2ebb6ce Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 0 Imported by: 0

README

Testing lambda and Alexa

Lambda

cat test/lambda_intent_request.json |
  docker run --rm -i -v "$PWD":/var/task -e DOCKER_LAMBDA_USE_STDIN=1 lambci/lambda:go1.x deploy/app

Simulate Alexa Skill

You can simulate a "full" dialog with Alexa, once the skill is deployed. So this should be done automatically at the end of a successful staging deploy, before deleting the stack again.

Limitations:

The ask dialog seems to not support dialogs with Alexa that don't involve lambda.

  • You cannot simulate a delegated slot confirmation ("Please confirm $slot...")
  • You cannot simulate dialog delegation (DirectiveTypeDialogDelegate) to Alexa ("Which $slot..."), e.g. lambda must respond with DirectiveTypeDialogElicitSlot

You can however test this in the developer console (https://developer.amazon.com/alexa/console/ask/test/).

Put some more things into your .env file:

  • ASKSkillId=amzn1.ask.skill.xxxxx from ask api list-skills
  • ASKLocale=de-DE
  • ASK_DEFAULT_PROFILE=default

Simulate launch:

ask simulate --skill-id $ASKSkillId --locale $ASKLocale \
  --text "Alexa öffne Demo Skill"

Record a dialog session:

ask dialog --skill-id $ASKSkillId --locale $ASKLocale --output ask-dialog.log
# now start with a dialog "alexa open <skill invocation>"
# at the end write `!record` to save the dialog to a file   

Replay a dialog session:

ask dialog --replay test/ask_de-DE_demointent.replay --output test/ask_de-DE-demointent.log
ask dialog --replay test/ask_de-DE_awsstatus.replay --output test/ask_de-DE-awsstatus.log
ask dialog --replay test/ask_en-US_awsstatus.replay --output test/ask_en-US-awsstatus.log

Validate Skill
ask validate --skill-id $ASKSkillId --locales en-US,de-DE

ask-cli docker

  • always requires a cli_config for ask, ENV is just to overwrite/select profile
cat << EOF > ask.env
ASK_DEFAULT_PROFILE=awsdev
ASK_ACCESS_TOKEN=Atza|IwE...
ASK_REFRESH_TOKEN=Atzr|IwE...
ASK_VENDOR_ID=M2...
EOF

docker run --rm --platform linux/amd64 -it \
    -v ${PWD}/test:/test -v ${PWD}/test/ask:/home/node/.ask \
    xavidop/alexa-ask-aws-cli bash

ask dialog --replay /test/ask_de-DE_awsstatus.replay

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bar

type Bar struct {
	// contains filtered or unexported fields
}

Bar implements only the sub interface.

func (*Bar) GetName

func (b *Bar) GetName() string

GetName returns the name.

func (*Bar) SetName

func (b *Bar) SetName(n string)

SetName sets the name.

type Foo

type Foo struct {
	// contains filtered or unexported fields
}

Foo implements both interfaces.

func (*Foo) GetInstance

func (f *Foo) GetInstance() MySubInterface

GetInstance returns the instance.

func (*Foo) GetName

func (f *Foo) GetName() string

GetName returns the name.

func (*Foo) SetInstance

func (f *Foo) SetInstance(i MySubInterface)

SetInstance sets the instance.

func (*Foo) SetName

func (f *Foo) SetName(n string)

SetName sets the name.

type MyInterface

type MyInterface interface {
	SetName(name string)
	// CANNOT be pointer!
	// link to an object complying to the sub interface
	SetInstance(i MySubInterface)
	GetInstance() MySubInterface
}

MyInterface is a test interface.

type MySubInterface

type MySubInterface interface {
	GetName() string
	SetName(name string)
}

MySubInterface is another test interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL