actions

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

This package works with Google Assistant Actions SDK and provides bindings to support json encoding and decoding for some data types. Enough functionality to get a webhook and fulfillment working with TakeoutFMFM is supported.

https://developers.google.com/assistant/conversational/overview https://developers.google.com/assistant/conversational/prompts

Index

Constants

View Source
const (
	GoogleAssistantSignature = "google-assistant-signature"

	MediaTypeAudio = "AUDIO"

	MediaControlPaused  = "PAUSED"
	MediaControlStopped = "STOPPED"

	CapabilitySpeech            = "SPEECH"
	CapabilityRichResponse      = "RICH_RESPONSE"
	CapabilityLongFormAudio     = "LONG_FORM_AUDIO"
	CapabilityInteractiveCanvas = "INTERACTIVE_CANVAS"
	CapabilityWebLink           = "WEB_LINK"
	CapabilityHomeStorage       = "HOME_STORAGE"

	VerificationStatusGuest    = "GUEST"
	VerificationStatusVerified = "VERIFIED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Card

type Card struct {
	Title    string `json:"title,omitempty"`
	Subtitle string `json:"subtitle,omitempty"`
	Text     string `json:"text,omitempty"`
	Image    *Image `json:"image,omitempty"`
}

type Content

type Content struct {
	Card  *Card  `json:"card"`  // basic card
	Image *Image `json:"image"` // image card
	Media *Media `json:"media"` // media
}

type Context

type Context struct {
	Media *MediaContext `json:"media"`
}

type Device

type Device struct {
	Capabilities []string  `json:"capabilities,omitempty"`
	TimeZone     *TimeZone `json:"timeZone"`
}

type Handler

type Handler struct {
	Name string `json:"name,omitempty"`
}

type Home

type Home struct {
	Params map[string]string `json:"params"`
}

type Image

type Image struct {
	Alt    string `json:"alt,omitempty"`
	URL    string `json:"url,omitempty"`
	Width  int    `json:"width,omitempty"`
	Height int    `json:"height,omitempty"`
}

type Intent

type Intent struct {
	Name   string  `json:"name,omitempty"`
	Params *Params `json:"params"`
	Query  string  `json:"query,omitempty"`
}

type Media

type Media struct {
	MediaObjects          []*MediaObject `json:"mediaObjects,omitempty"`
	MediaType             string         `json:"mediaType,omitempty"`
	OptionalMediaControls []string       `json:"optionalMediaControls,omitempty"`
	RepeatMode            string         `json:"repeatMode,omitempty"`
}

type MediaContext

type MediaContext struct {
	Index    int    `json:"index,omitempty"`
	Progress string `json:"progress,omitempty"`
}

type MediaImage

type MediaImage struct {
	Large *Image `json:"large"`
	Icon  *Image `json:"icon"`
}

type MediaObject

type MediaObject struct {
	Name        string      `json:"name,omitempty"`
	Description string      `json:"description,omitempty"`
	URL         string      `json:"url,omitempty"`
	Image       *MediaImage `json:"image"`
}

type Param

type Param struct {
	Original string `json:"original,omitempty"`
	Resolved string `json:"resolved,omitempty"`
}

type Params

type Params struct {
	Artist  *Param `json:"artist"`
	Song    *Param `json:"song"`
	Release *Param `json:"release"`
	Radio   *Param `json:"radio"`
	Popular *Param `json:"popular"`
	Latest  *Param `json:"latest"`
	Any     *Param `json:"any"`
}

These params are Takeout specific. Included here to make overall json handing easier.

type Prompt

type Prompt struct {
	Override    bool            `json:"override"`
	Content     *Content        `json:"content"`
	FirstSimple *SimpleResponse `json:"firstSimple"`
	LastSimple  *SimpleResponse `json:"lastSimple"`
	Suggestions []*Suggestion   `json:"suggestions,omitempty"`
}

type Scene

type Scene struct {
	Name string `json:"name,omitempty"`
}

type Session

type Session struct {
	ID           string            `json:"id,omitempty"`
	Params       map[string]string `json:"params"`
	LanguageCode string            `json:"languageCode,omitempty"`
}

type SimpleResponse

type SimpleResponse struct {
	Speech string `json:"speech,omitempty"`
	Text   string `json:"text,omitempty"`
}

type Suggestion

type Suggestion struct {
	Title string `json:"title,omitempty"`
}

type TimeZone

type TimeZone struct {
	ID      string `json:"id,omitempty"`
	Version string `json:"version,omitempty"`
}

type User

type User struct {
	Params               map[string]string `json:"params"`
	Locale               string            `json:"locale,omitempty"`
	AccountLinkingStatus string            `json:"accountLinkingStatus,omitempty"`
	VerificationStatus   string            `json:"verificationStatus,omitempty"`
	LastSeenTime         string            `json:"lastSeenTime,omitempty"`
}

type WebhookRequest

type WebhookRequest struct {
	Handler *Handler `json:"handler"`
	Intent  *Intent  `json:"intent"`
	Scene   *Scene   `json:"scene"`
	Session *Session `json:"session"`
	User    *User    `json:"user"`
	Home    *Home    `json:"home"`
	Device  *Device  `json:"device"`
	Context *Context `json:"Context"`
}

func NewWebhookRequest

func NewWebhookRequest(r *http.Request) *WebhookRequest

func (WebhookRequest) AnyParam

func (r WebhookRequest) AnyParam() string

func (WebhookRequest) ArtistParam

func (r WebhookRequest) ArtistParam() string

func (WebhookRequest) IntentName

func (r WebhookRequest) IntentName() string

func (WebhookRequest) LatestParam

func (r WebhookRequest) LatestParam() string

func (WebhookRequest) PopularParam

func (r WebhookRequest) PopularParam() string

func (WebhookRequest) RadioParam

func (r WebhookRequest) RadioParam() string

func (WebhookRequest) ReleaseParam

func (r WebhookRequest) ReleaseParam() string

func (*WebhookRequest) SessionParam

func (r *WebhookRequest) SessionParam(name string) string

func (WebhookRequest) SongParam

func (r WebhookRequest) SongParam() string

func (WebhookRequest) SupportsMedia

func (r WebhookRequest) SupportsMedia() bool

func (WebhookRequest) SupportsRichResponse

func (r WebhookRequest) SupportsRichResponse() bool

func (*WebhookRequest) UserParam

func (r *WebhookRequest) UserParam(name string) string

func (WebhookRequest) Verified

func (r WebhookRequest) Verified() bool

func (WebhookRequest) VerifiedStatus

func (r WebhookRequest) VerifiedStatus() string

type WebhookResponse

type WebhookResponse struct {
	Session *Session `json:"session"`
	User    *User    `json:"user"`
	Home    *Home    `json:"home"`
	Prompt  *Prompt  `json:"prompt"`
}

func NewWebhookResponse

func NewWebhookResponse(r *WebhookRequest) *WebhookResponse

func (*WebhookResponse) AddMedia

func (r *WebhookResponse) AddMedia(name, desc, url, image string)

func (*WebhookResponse) AddSession

func (r *WebhookResponse) AddSession(id string)

func (*WebhookResponse) AddSessionParam

func (r *WebhookResponse) AddSessionParam(name, value string)

func (*WebhookResponse) AddSimple

func (r *WebhookResponse) AddSimple(speech, text string)

func (*WebhookResponse) AddSuggestions

func (r *WebhookResponse) AddSuggestions(suggestions ...string)

func (*WebhookResponse) AddUserParam

func (r *WebhookResponse) AddUserParam(name, value string)

func (*WebhookResponse) Send

func (h *WebhookResponse) Send(w http.ResponseWriter)

func (*WebhookResponse) SessionParam

func (r *WebhookResponse) SessionParam(name string) string

func (*WebhookResponse) UserParam

func (r *WebhookResponse) UserParam(name string) string

Jump to

Keyboard shortcuts

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