mydemoskill

package module
v0.0.0-...-00a9b86 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 7 Imported by: 0

README

Workflow Status Coverage Status Contributors GitHub pull requests GitHub closed pull requests GitHub stars

go-alexa-lambda-template

Template project using go-alexa-lambda library.

How to use it

Checkout the template
# this must be in your GOPATH, e.g. in the path to your git repo (see below)
git clone https://github.com/DrPsychick/go-alexa-lambda-template.git
mv go-alexa-lambda-template my-skill-name
cd my-skill-name
rm -rf .git
Test, build and run it
# Makefile requires mmake
go install github.com/tj/mmake/cmd/mmake@v1.4.0
alias make='mmake'
make test
make build

# generate skill and interactionModel(s)
./mydemoskill make --skill --models
ls -la ./alexa/skill.json ./alexa/*/*/en-US.json

# test how lambda responds to a launch request
./test/test-lambda.sh launch
Push it to your own git
# create your own git repo and push it
GITREPO=github.com/yourname/yourproject
git init .
git remote add origin https://$GITREPO.git
# replace module paths of the template with your own
find . -name \*.go -exec sed -i "" -e "s#github.com/drpsychick/go-alexa-lambda-template#$GITREPO#" {} ';'
git add .
git commit -m "initial commit"
git push

Build your own skill

Replace existing Intent with your own

This templates is ready to use with an existing demo intent. Here are some example phrases:

  • Alexa open my demo skill and make coffee.
  • Alexa prepare lunch with my demo skill.
  • Alexa start my demo skill. Yes? Sudo make me a sandwich.

To replace it with your own first intent, do the following:

Replace sample constants and translations

  • Replace Intent and Slot name in loca/loca.go
    • Replace DoSomething with your intent name
    • Replace Task with your slot type
  • Update your english locale accordingly loca/en-US.go
    • Like above replace DoSomething and Task
    • Change texts and phrases to match your intent.
  • Make sure all references to the changed loca. constants are updated in all files.

Replace demo with your own logic

  • Adjust skill.go to define your skill manifest and interaction model.
  • Adjust app.go and add the behavioural or business logic for your intents.
  • Adjust lambda/lambda.go to add more intents or change how to process Alexa requests.
  • Of course, adjust loca files to your needs, adding keys and changing texts.

Verify skill manifest and interaction model

  • run make build; ./mydemoskill make --skill --models
  • check alexa/skill.json and alexa/interactionModel/custom/en-US.json

Before you code

Interaction concept

Make a concept for your skill on how people will interact with it, e.g. use a mind map.

  • How will users launch it?
  • How will users interact with your skill?
  • Write down example phrases and dialogs with your skill.
  • Read them out loud and check if it "feels" like a smooth conversation.
  • Make sure to repeat the above steps for every language (locale). Especially your invocation will likely be specific to the locale.

Testing your skill

  • Create sample lambda requests to ensure your lambda function answers correctly.
  • Create a few common dialogs you want to have tested after deploy.
    • Important: ask cli dialog does not work with prompts delegated to Alexa! It will just timeout.
  • Manually test dialogs with prompt delegation to Alexa with the Alexa SDK website.

Documentation

Overview

Package mydemoskill is the core app functionality.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknown = errors.New("something went wrong")

ErrUnknown is the fallback error.

Functions

func CreateSkillModels

func CreateSkillModels(s *skill.SkillBuilder) (map[string]*skill.Model, error)

CreateSkillModels generates and returns a list of Models.

func NewSkill

func NewSkill() *skill.SkillBuilder

NewSkill returns a configured SkillBuilder.

Types

type Application

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

Application defines the base application.

func NewApplication

func NewApplication(l *logger.Logger, s *statter.Statter) *Application

NewApplication returns an Application with the logger and statter.

func (*Application) Cancel

func (a *Application) Cancel(loc l10n.LocaleInstance, opts ...ResponseFunc) (alexa.Response, error)

Cancel cancels the skill session.

func (*Application) DoSomething

func (a *Application) DoSomething(loc l10n.LocaleInstance, task string, opts ...ResponseFunc,
) (alexa.Response, error)

DoSomething triggers the start of a server and returns the result.

func (*Application) ElicitServer

func (a *Application) ElicitServer(loc l10n.LocaleInstance, server string) (alexa.Response, error)

ElicitServer reprompts for a valid server name.

func (*Application) Help

func (a *Application) Help(loc l10n.LocaleInstance, opts ...ResponseFunc) (alexa.Response, error)

Help returns a response that explains how to use the skill.

func (*Application) Launch

func (a *Application) Launch(loc l10n.LocaleInstance, opts ...ResponseFunc) (alexa.Response, error)

Launch starts a skill session.

func (*Application) Logger

func (a *Application) Logger() *logger.Logger

Logger returns the application logger.

func (*Application) Statter

func (a *Application) Statter() *statter.Statter

Statter returns the application statter.

func (*Application) Stop

func (a *Application) Stop(loc l10n.LocaleInstance, opts ...ResponseFunc) (alexa.Response, error)

Stop ends the skill session.

type Config

type Config struct {
	User string
}

Config defines additional data that can be provided and used in requests.

type ResponseFunc

type ResponseFunc func(cfg *Config)

ResponseFunc defines the function that can optionally be passed to responses.

func WithUser

func WithUser(user string) ResponseFunc

WithUser returns a ResponseFunc that sets the user.

Directories

Path Synopsis
cmd
Package lambda defines how to handle requests and returns proper responses.
Package lambda defines how to handle requests and returns proper responses.
middleware
Package middleware contains middlewares for lambda.
Package middleware contains middlewares for lambda.
Package loca contains all translations.
Package loca contains all translations.

Jump to

Keyboard shortcuts

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