skillgo

package module
v0.0.0-...-eb843b7 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2021 License: MIT Imports: 1 Imported by: 0

README

skillgo

Kakao Skill Payload Version Go Report Card

📦 Go 을 위한 kakao i open builder skill 응답 포맷 생성 모듈

🗞️ Docs - pkg.go.dev
🟡 JavaScript Version

설치

go get github.com/cjaewon/skillgo

주요 타입

이름 타입
SkillPayload SkillPayload
SkillResponse SkillResponse
SkillTemplate SkillTemplate
ContextControl ContextControl
QuickReplies QuickReplies

지원하는 SkillResponse

기본
SkillResponse 타입 (struct) 함수 이름
SimpleText SimpleTextType SimpleText
SimpleImage SimpleImageType SimpleImage
BasicCard BasicCardType BasicCard
CommerceCard CommerceCardType CommerceCard
ListCard ListCardType ListCard
Carousel CarouselType Carousel
공통

kakao i 오픈빌더 공통

SkillResponse 타입 (struct) 함수 이름
Thumbnail ThumbnailType Thumbnail
Link LinkType Link
Button ButtonType Button
Profile ProfileType Profile
CarouselHeader CarouselHeaderType CarouselHeader

예제

📄 Simple (SimpleText, SimpleImage)
📄 Card (BasicCard, CommerceCard, Listcard)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionConfig

type ActionConfig struct {
	WebLinkURL  string                 `json:"webLinkUrl,omitempty"`
	MessageText string                 `json:"messageText,omitempty"`
	PhoneNumber string                 `json:"phoneNumber,omitempty"`
	BlockID     map[string]interface{} `json:"blockId,omitempty"`
}

ActionConfig represents actions

type BasicCardType

type BasicCardType struct {
	BasicCard struct {
		Title       string        `json:"title,omitempty"`
		Description string        `json:"description,omitempty"`
		Thumbnail   ThumbnailType `json:"thumbnail"`
		// Profile 미지원
		Profile struct {
			ImageURL string `json:"imageUrl"`
			Nickname string `json:"nickname"`
		} `json:"profile,omitempty"`
		// Social 미지원
		Social struct {
			Like    int `json:"like"`
			Comment int `json:"comment"`
			Share   int `json:"share"`
		} `json:"social,omitempty"`
		Buttons []ButtonType `json:"buttons,omitempty"`
	} `json:"basicCard"`
}

BasicCardType is BasicCard template

func BasicCard

func BasicCard(title string, description string, thumbnail ThumbnailType, buttons []ButtonType) BasicCardType

BasicCard creates BasicCard SkillResponse

type ButtonType

type ButtonType struct {
	Label  string `json:"label"`
	Action string `json:"action"`
	ActionConfig
}

ButtonType is Button Template

func Button

func Button(label string, action string, config ActionConfig) ButtonType

Button creates Button SkillResponse

type CarouselHeaderType

type CarouselHeaderType struct {
	Title       string        `json:"title"`
	Description string        `json:"description"`
	Thumbnail   ThumbnailType `json:"thumbnail"`
}

CarouselHeaderType is CarouselHeader Template which located in Carousel

func CarouselHeader

func CarouselHeader(title string, description string, thumbnail ThumbnailType) CarouselHeaderType

CarouselHeader creates CarouselHeader SkillResponse

type CarouselType

type CarouselType struct {
	Type string `json:"type"`
	// BasicCardType, CommerceCard
	Items  []interface{}      `json:"items"`
	Header CarouselHeaderType `json:"header,omitempty"`
}

CarouselType is Carousel template

func Carousel(Type string, items []interface{}, header CarouselHeaderType) CarouselType

Carousel creates Carousel SkillResponse

type CommerceCardType

type CommerceCardType struct {
	CommerceCard struct {
		Description     string          `json:"description"`
		Price           int             `json:"price"`
		Currency        string          `json:"currency"`
		Discount        int             `json:"discount,omitempty"`
		DiscountRate    int             `json:"discountRate,omitempty"`
		DiscountedPrice int             `json:"dicountedPrice,omitempty"`
		Thumbnails      []ThumbnailType `json:"thumbnails"`
		Profile         ProfileType     `json:"profile,omitempty"`
		Buttons         []ButtonType    `json:"buttons"`
	} `json:"commerceCard"`
}

CommerceCardType is CommerceCard template

func CommerceCard

func CommerceCard(
	description string,
	price int,
	currency string,
	discount int,
	discountRate int,
	discountedPrice int,
	thumbnails []ThumbnailType,
	profile ProfileType,
	buttons []ButtonType,
) CommerceCardType

CommerceCard creates CommerceCard SkillResponse

type ContextControl

type ContextControl struct {
	Values []struct {
		Name     string            `json:"name"`
		LifeSpan int               `json:"lifeSpan"`
		Params   map[string]string `json:"params,omitempty"`
	}
}

ContextControl is context of message

type LinkType

type LinkType struct {
	PC     string `json:"pc,omitempty"`
	Mobile string `json:"mobile,omitempty"`
	Web    string `json:"web,omitempty"`
}

LinkType is Link template

func Link(pc string, mobile string, web string) LinkType

Link creates Link SkillResponse

type ListCardType

type ListCardType struct {
	ListCard struct {
		Header  ListItemType   `json:"header"`
		Items   []ListItemType `json:"items"`
		Buttons []ButtonType   `json:"buttons,omitempty"`
	} `json:"listCard"`
}

ListCardType is ListCard template

func ListCard

func ListCard(header ListItemType, items []ListItemType, buttons []ButtonType) ListCardType

ListCard creates ListCard SkillResponse

type ListItemType

type ListItemType struct {
	Title       string   `json:"title"`
	Description string   `json:"description,omitempty"`
	ImageURL    string   `json:"imageUrl,omitempty"`
	Link        LinkType `json:"link,omitempty"`
}

ListItemType is ListItem template

func ListItem

func ListItem(title string, description string, imageURL string, link LinkType) ListItemType

ListItem creates ListItem for ListCard

type ProfileType

type ProfileType struct {
	Nickname string `json:"nickname"`
	ImageURL string `json:"imageUrl"`
}

ProfileType is Profile template

func Profile

func Profile(nickname string, imageURL string) ProfileType

Profile creates Profile SkillResponse

type QuickRepliesType

type QuickRepliesType struct {
	Label       string      `json:"label"`
	Action      string      `json:"action"`
	MessageText string      `json:"messageText,omitempty"`
	BlockID     string      `json:"blockId,omitempty"`
	Extra       interface{} `json:"extra,omitempty"`
}

QuickRepliesType is QucikReplies Template

func QuickReplies

func QuickReplies(label string, action string, messageText string, blockID string, extra interface{}) QuickRepliesType

QuickReplies creates QuickReplies SkillResponse

type SimpleImageType

type SimpleImageType struct {
	SimpleImage struct {
		ImageURL string `json:"imageUrl"`
		AltText  string `json:"altText"`
	} `json:"simpleImage"`
}

SimpleImageType is SimpleImage Template which located in SkillTemplate.Outputs

func SimpleImage

func SimpleImage(imageURL string, altText string) SimpleImageType

SimpleImage creates SimpleImage SkillResponse

type SimpleTextType

type SimpleTextType struct {
	SimpleText struct {
		Text string `json:"text"`
	} `json:"simpleText"`
}

SimpleTextType is SimpleText Template which located in SkillTemplate.Outputs

func SimpleText

func SimpleText(text string) SimpleTextType

SimpleText creates SimpleTextType SkillResponse

type SkillPayload

type SkillPayload struct {
	UserRequest struct {
		Timezone string                 `json:"timezone"`
		Params   map[string]interface{} `json:"params"`
		Block    struct {
			ID   string `json:"id"`
			Name string `json:"name"`
		} `json:"block"`
		Utterance string `json:"utterance"`
		Lang      string `json:"lang"`
		User      struct {
			ID         string `json:"id"`
			Type       string `json:"type"`
			Properties struct {
				PlusfriendUserKey string `json:"plusfriendUserKey"`
			} `json:"properties"`
		} `json:"user"`
	} `json:"userRequest"`
	Contexts []interface{} `json:"contexts"`
	Bot      struct {
		ID   string `json:"id"`
		Name string `json:"name"`
	} `json:"bot"`
	Action struct {
		Name        string            `json:"name"`
		ClientExtra map[string]string `json:"clientExtra"`
		Params      struct {
		} `json:"params"`
		ID           string `json:"id"`
		DetailParams struct {
		} `json:"detailParams"`
	} `json:"action"`
}

SkillPayload is the payload which was passed by kakao i open builder server

type SkillResponse

type SkillResponse struct {
	Version  string        `json:"version"`
	Template SkillTemplate `json:"template,omitempty"`

	Context interface{} `json:"context,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

SkillResponse is the response which pass to kakao i open builder server

type SkillTemplate

type SkillTemplate struct {
	Outputs      []interface{}      `json:"outputs,omitempty"`
	QuickReplies []QuickRepliesType `json:"quickReplies,omitempty"`
}

SkillTemplate is the template which represents a message

type ThumbnailType

type ThumbnailType struct {
	ImageURL   string   `json:"imageUrl"`
	Link       LinkType `json:"link,omitempty"`
	FixedRatio bool     `json:"fixedRatio,omitempty"`
	Width      int      `json:"width,omitempty"`
	Height     int      `json:"height,omitempty"`
}

ThumbnailType is Thumbnail template which located in CarouselHeaderType

func Thumbnail

func Thumbnail(imageURL string, link LinkType, fixedRatio bool, width int, height int) ThumbnailType

Thumbnail creates Thumbnail SkillResponse

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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