response

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APLDATATYPE = "Alexa.Presentation.APL.RenderDocument"
	APLVERSION  = "1.0"
)
View Source
const (
	PERMISSION_FULLNAME                = "alexa::profile:name:read"
	PERMISSION_FIRSTNAME               = "alexa::profile:given_name:read"
	PERMISSION_EMAIL                   = "alexa::profile:email:read"
	PERMISSION_MOBILE                  = "alexa::profile:mobile_number:read"
	PERMISSION_COUNTRY_AND_POSTAL_CODE = "read::alexa:device:all:address:country_and_postal_code"
	PERMISSION_ADDRESS                 = "read::alexa:device:all:address"
)
View Source
const (
	GENERATOR = "alexa-1.0.0/Webability/GO"

	IMAGESOURCE_X_SMALL = "X_SMALL"
	IMAGESOURCE_SMALL   = "SMALL"
	IMAGESOURCE_MEDIUM  = "MEDIUM"
	IMAGESOURCE_LARGE   = "LARGE"
	IMAGESOURCE_X_LARGE = "X_LARGE"
)
View Source
const (
	TEMPLATE_BUTTON_VISIBLE = "VISIBLE"
	TEMPLATE_BUTTON_HIDDEN  = "HIDDEN"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APLBuilder

type APLBuilder struct {
	Datatype    string
	Version     string
	Document    string
	DataSources *APLDataSources
}

func NewAPLBuilder

func NewAPLBuilder(document string, datasources *APLDataSources) *APLBuilder

func (*APLBuilder) Build

func (builder *APLBuilder) Build() Directive

type APLDataSource

type APLDataSource map[string]interface{}

func (*APLDataSource) AddData

func (ds *APLDataSource) AddData(id string, val interface{})

func (*APLDataSource) NewDataList

func (ds *APLDataSource) NewDataList(id string) *APLDataSourceList

func (*APLDataSource) NewDataSet

func (ds *APLDataSource) NewDataSet(id string) *APLDataSource

type APLDataSourceList

type APLDataSourceList []APLDataSource

func (*APLDataSourceList) NewDataListItem

func (ds *APLDataSourceList) NewDataListItem() *APLDataSource

type APLDataSources

type APLDataSources map[string]interface{}

func NewAPLDataSources

func NewAPLDataSources() *APLDataSources

func (*APLDataSources) NewDataSource

func (ds *APLDataSources) NewDataSource(id string, objecttype string) *APLDataSource

type APLDocument

type APLDocument map[string]interface{}

type AlexaResponse

type AlexaResponse struct {
	Version           string      `json:"version"`
	SessionAttributes interface{} `json:"sessionAttributes,omitempty"` // can be empty (nil)
	Response          Response    `json:"response"`                    // response is mandatory (not a pointer *)
	UserAgent         string      `json:"userAgent"`
}

MAIN ALEXA RESPONSE STRUCTURE

func NewResponse

func NewResponse(close *bool) *AlexaResponse

Basic Response creator

func NewSSMLResponse

func NewSSMLResponse(text string, close bool) *AlexaResponse

disappear this function wher NewTextResponse is done

func NewSimpleResponse

func NewSimpleResponse(title string, text string, close bool) *AlexaResponse

func NewTextResponse

func NewTextResponse(text interface{}, close bool) *AlexaResponse

Some Common responses pre-build Text response: be intelligent: if text is string and no tags, simple text if text is string and some tags: ssml text, check if <speak> is here and adds it if not if text is ssml speech object, build it and inject it as ssml text

func (*AlexaResponse) AddAPL

func (r *AlexaResponse) AddAPL(apl *APLBuilder)

func (*AlexaResponse) AddAttributes

func (r *AlexaResponse) AddAttributes(attributes interface{}) *AlexaResponse

Add things to the response

func (*AlexaResponse) AddCard

func (r *AlexaResponse) AddCard(card *CardBuilder)

func (*AlexaResponse) AddSpeech

func (r *AlexaResponse) AddSpeech(speech *SSMLBuilder)

func (*AlexaResponse) AddTemplate

func (r *AlexaResponse) AddTemplate(template TemplateBuilder)

func (*AlexaResponse) AddVideo

func (r *AlexaResponse) AddVideo(video *DirectiveVideoAppLaunch)

type AudioMetaData

type AudioMetaData struct {
	Title           string        `json:"title,omitempty"`
	Subtitle        string        `json:"subtitle,omitempty"`
	Art             *DisplayImage `json:"art,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
}

type BodyTemplate1

type BodyTemplate1 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	TextContent     *TextContent  `json:"textContent,omitempty"`
}

func (*BodyTemplate1) Build

func (builder *BodyTemplate1) Build() Directive

func (*BodyTemplate1) WithBackButton

func (builder *BodyTemplate1) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*BodyTemplate1) WithBackgroundImage

func (builder *BodyTemplate1) WithBackgroundImage(image string) *DisplayImage

func (*BodyTemplate1) WithPrimaryText

func (builder *BodyTemplate1) WithPrimaryText(text string) *TextContent

func (*BodyTemplate1) WithTitle

func (builder *BodyTemplate1) WithTitle(title string)

func (*BodyTemplate1) WithToken

func (builder *BodyTemplate1) WithToken(token string)

type BodyTemplate2

type BodyTemplate2 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	Image           *DisplayImage `json:"image,omitempty"`
	TextContent     *TextContent  `json:"textContent,omitempty"`
}

func (*BodyTemplate2) Build

func (builder *BodyTemplate2) Build() Directive

func (*BodyTemplate2) WithBackButton

func (builder *BodyTemplate2) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*BodyTemplate2) WithBackgroundImage

func (builder *BodyTemplate2) WithBackgroundImage(image string) *DisplayImage

func (*BodyTemplate2) WithImage

func (builder *BodyTemplate2) WithImage(image string) *DisplayImage

func (*BodyTemplate2) WithPrimaryText

func (builder *BodyTemplate2) WithPrimaryText(text string) *TextContent

func (*BodyTemplate2) WithTitle

func (builder *BodyTemplate2) WithTitle(title string)

func (*BodyTemplate2) WithToken

func (builder *BodyTemplate2) WithToken(token string)

type BodyTemplate3

type BodyTemplate3 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	Image           *DisplayImage `json:"image,omitempty"`
	TextContent     *TextContent  `json:"textContent,omitempty"`
}

func (*BodyTemplate3) Build

func (builder *BodyTemplate3) Build() Directive

func (*BodyTemplate3) WithBackButton

func (builder *BodyTemplate3) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*BodyTemplate3) WithBackgroundImage

func (builder *BodyTemplate3) WithBackgroundImage(image string) *DisplayImage

func (*BodyTemplate3) WithImage

func (builder *BodyTemplate3) WithImage(image string) *DisplayImage

func (*BodyTemplate3) WithPrimaryText

func (builder *BodyTemplate3) WithPrimaryText(text string) *TextContent

func (*BodyTemplate3) WithTitle

func (builder *BodyTemplate3) WithTitle(title string)

func (*BodyTemplate3) WithToken

func (builder *BodyTemplate3) WithToken(token string)

type BodyTemplate6

type BodyTemplate6 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Image           *DisplayImage `json:"image,omitempty"`
	TextContent     *TextContent  `json:"textContent,omitempty"`
}

func (*BodyTemplate6) Build

func (builder *BodyTemplate6) Build() Directive

func (*BodyTemplate6) WithBackButton

func (builder *BodyTemplate6) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*BodyTemplate6) WithBackgroundImage

func (builder *BodyTemplate6) WithBackgroundImage(image string) *DisplayImage

func (*BodyTemplate6) WithImage

func (builder *BodyTemplate6) WithImage(image string) *DisplayImage

func (*BodyTemplate6) WithPrimaryText

func (builder *BodyTemplate6) WithPrimaryText(text string) *TextContent

func (*BodyTemplate6) WithToken

func (builder *BodyTemplate6) WithToken(token string)

type BodyTemplate7

type BodyTemplate7 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	Image           *DisplayImage `json:"image,omitempty"`
}

func (*BodyTemplate7) Build

func (builder *BodyTemplate7) Build() Directive

func (*BodyTemplate7) WithBackButton

func (builder *BodyTemplate7) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*BodyTemplate7) WithBackgroundImage

func (builder *BodyTemplate7) WithBackgroundImage(image string) *DisplayImage

func (*BodyTemplate7) WithImage

func (builder *BodyTemplate7) WithImage(image string) *DisplayImage

func (*BodyTemplate7) WithTitle

func (builder *BodyTemplate7) WithTitle(title string)

func (*BodyTemplate7) WithToken

func (builder *BodyTemplate7) WithToken(token string)

type Card

type Card struct {
	Type        string     `json:"type"`
	Title       string     `json:"title,omitempty"`
	Content     string     `json:"content,omitempty"`
	Text        string     `json:"text,omitempty"`
	Image       *CardImage `json:"image,omitempty"`
	Permissions []string   `json:"permissions,omitempty"`
}

Card object

type CardBuilder

type CardBuilder struct {
	Type        string
	Title       string
	Message     string
	Image       string
	Icon        string
	Permissions []string
}

func NewCardBuilder

func NewCardBuilder(title string, message string, image string, icon string) *CardBuilder

main builder

func NewLinkAccountCardBuilder

func NewLinkAccountCardBuilder(title string, message string, image string, icon string) *CardBuilder

Link account: login with oauth or basic

func NewPermissionCardBuilder

func NewPermissionCardBuilder(permissions []string) *CardBuilder

Ask for permission card

func NewSimpleCardBuilder

func NewSimpleCardBuilder(title string, message string, image string, icon string) *CardBuilder

Simple card: no image

func NewStandardCardBuilder

func NewStandardCardBuilder(title string, message string, image string, icon string) *CardBuilder

Standard card: with image

func (*CardBuilder) Build

func (builder *CardBuilder) Build() *Card

Build the code for the specified card

type CardImage

type CardImage struct {
	SmallImageURL string `json:"smallImageUrl,omitempty"`
	LargeImageURL string `json:"largeImageUrl,omitempty"`
}

Images for a card

type Directive

type Directive interface{}

Directives for audio, video, display, dialog

type DirectiveAPL

type DirectiveAPL struct {
	DirectiveCommon
	Document    APLDocument     `json:"document"`
	Datasources *APLDataSources `json:"datasources,omitempty"`
	Token       string          `json:"token"`
}

APL Templates

type DirectiveAudioClearQueue

type DirectiveAudioClearQueue struct {
	DirectiveCommon
	ClearBehavior string `json:"playBehavior"`
}

type DirectiveAudioPlay

type DirectiveAudioPlay struct {
	DirectiveCommon
	PlayBehavior string `json:"playBehavior"`
	AudioItem    struct {
		Stream struct {
			URL   string `json:"url"`
			Token string `json:"token"`

			OffsetInMilliseconds int `json:"offsetInMilliseconds"`
			// contains filtered or unexported fields
		} `json:"stream"`
		Metadata *AudioMetaData `json:"token,omitempty"`
	} `json:"audioItem"`
}

AUDIO PLAY DIRECTIVE

type DirectiveAudioStop

type DirectiveAudioStop struct {
	DirectiveCommon
}

type DirectiveCommon

type DirectiveCommon struct {
	Type string `json:"type"`
}

type DirectiveRenderTemplate

type DirectiveRenderTemplate struct {
	DirectiveCommon
	Template Template `json:"template"`
}

Render Templates

type DirectiveVideoAppLaunch

type DirectiveVideoAppLaunch struct {
	DirectiveCommon
	VideoItem struct {
		Source   string         `json:"source"`
		Metadata *VideoMetadata `json:"metadata,omitempty"`
	} `json:"videoItem"`
}

VIDEO PLAY DIRECTIVE

type DisplayImage

type DisplayImage struct {
	ContentDescription string         `json:"contentDescription"`
	Sources            *[]ImageSource `json:"sources"`
}

Basic objects for directives

func (*DisplayImage) AddSource

func (di *DisplayImage) AddSource(url string) *ImageSource

type ImageSource

type ImageSource struct {
	URL          string `json:"url"`
	Size         string `json:"size,omitempty"`
	WidthPixels  int    `json:"widthPixels,omitempty"`
	HeightPixels int    `json:"heightPixels,omitempty"`
}

func (*ImageSource) WithSize

func (is *ImageSource) WithSize(size string, width int, height int)

size is IMAGESOURCE_X_SMALL to X_LARGE if width or height are 0, they are ignored

func (*ImageSource) WithURL

func (is *ImageSource) WithURL(url string)

type ListItem

type ListItem struct {
	Token       string        `json:"token,omitempty"`
	Image       *DisplayImage `json:"image,omitempty"`
	TextContent *TextContent  `json:"textContent,omitempty"`
}

type ListTemplate1

type ListTemplate1 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	ListItems       *[]ListItem   `json:"listItems,omitempty"`
}

func (*ListTemplate1) AddListItem

func (builder *ListTemplate1) AddListItem(token string, image string, text string) *ListItem

func (*ListTemplate1) Build

func (builder *ListTemplate1) Build() Directive

func (*ListTemplate1) WithBackButton

func (builder *ListTemplate1) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*ListTemplate1) WithBackgroundImage

func (builder *ListTemplate1) WithBackgroundImage(image string) *DisplayImage

func (*ListTemplate1) WithTitle

func (builder *ListTemplate1) WithTitle(title string)

func (*ListTemplate1) WithToken

func (builder *ListTemplate1) WithToken(token string)

type ListTemplate2

type ListTemplate2 struct {
	TemplateCommon
	Token           string        `json:"token,omitempty"`
	BackButton      string        `json:"backButton,omitempty"`
	BackgroundImage *DisplayImage `json:"backgroundImage,omitempty"`
	Title           string        `json:"title,omitempty"`
	ListItems       *[]ListItem   `json:"listItems,omitempty"`
}

func (*ListTemplate2) AddListItem

func (builder *ListTemplate2) AddListItem(token string, image string, text string) *ListItem

func (*ListTemplate2) Build

func (builder *ListTemplate2) Build() Directive

func (*ListTemplate2) WithBackButton

func (builder *ListTemplate2) WithBackButton(button string)

use TEMPLATE_BUTTON_VISIBLE and TEMPLATE_BUTTON_HIDDEN as parameter

func (*ListTemplate2) WithBackgroundImage

func (builder *ListTemplate2) WithBackgroundImage(image string) *DisplayImage

func (*ListTemplate2) WithTitle

func (builder *ListTemplate2) WithTitle(title string)

func (*ListTemplate2) WithToken

func (builder *ListTemplate2) WithToken(token string)

type OutputSpeech

type OutputSpeech struct {
	Type         string `json:"type"`
	Text         string `json:"text,omitempty"`
	SSML         string `json:"ssml,omitempty"`
	PlayBehavior string `json:"playBehavior,omitempty"`
}

OutputSpeech object

type Reprompt

type Reprompt struct {
	OutputSpeech *OutputSpeech `json:"outputSpeech,omitempty"` // optional
}

Reprompt object

type Response

type Response struct {
	OutputSpeech     *OutputSpeech `json:"outputSpeech,omitempty"`
	Card             *Card         `json:"card,omitempty"`
	Reprompt         *Reprompt     `json:"reprompt,omitempty"`
	Directives       *[]Directive  `json:"directives,omitempty"`
	ShouldEndSession *bool         `json:"shouldEndSession,omitempty"`
}

Response structures

type SSML

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

type SSMLBuilder

type SSMLBuilder struct {
	SSML []SSML
}

func NewSSMLBuilder

func NewSSMLBuilder() *SSMLBuilder

func (*SSMLBuilder) AddEffect

func (builder *SSMLBuilder) AddEffect(data string)

func (*SSMLBuilder) AddEmphasis

func (builder *SSMLBuilder) AddEmphasis(data string)

func (*SSMLBuilder) AddLang

func (builder *SSMLBuilder) AddLang(data string)

func (*SSMLBuilder) AddSayAs

func (builder *SSMLBuilder) AddSayAs(data string, format string)

func (*SSMLBuilder) AddVoice

func (builder *SSMLBuilder) AddVoice(data string)

func (*SSMLBuilder) Audio

func (builder *SSMLBuilder) Audio(text string)

text is the audio source

func (*SSMLBuilder) Break

func (builder *SSMLBuilder) Break(text string)

text is the break time

func (*SSMLBuilder) Build

func (builder *SSMLBuilder) Build() string

func (*SSMLBuilder) Raw

func (builder *SSMLBuilder) Raw(text string)

text is the text to say

func (*SSMLBuilder) Say

func (builder *SSMLBuilder) Say(text string)

func (*SSMLBuilder) SetParagraph

func (builder *SSMLBuilder) SetParagraph()

func (*SSMLBuilder) SetSentence

func (builder *SSMLBuilder) SetSentence()

type Template

type Template interface{}

type TemplateBuilder

type TemplateBuilder interface {
	Build() Directive
}

func NewTemplateBuilder

func NewTemplateBuilder(templatetype string) TemplateBuilder

type TemplateCommon

type TemplateCommon struct {
	Type string `json:"type"`
}

type TextContent

type TextContent struct {
	PrimaryText   *TextField `json:"primaryText"`
	SecondaryText *TextField `json:"secondaryText,omitempty"`
	TertiaryText  *TextField `json:"tertiaryText,omitempty"`
}

func (*TextContent) WithPrimaryText

func (tc *TextContent) WithPrimaryText(text string)

func (*TextContent) WithSecondaryText

func (tc *TextContent) WithSecondaryText(text string)

func (*TextContent) WithTertiaryText

func (tc *TextContent) WithTertiaryText(text string)

type TextField

type TextField struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type VideoMetadata

type VideoMetadata struct {
	Title    string `json:"title,omitempty"`
	Subtitle string `json:"subtitle,omitempty"`
}

Jump to

Keyboard shortcuts

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