gcp_dialogflow

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateContext

func GenerateContext(projectId, sessionId, contextId string) (string, error)

func GenerateIntent

func GenerateIntent(projectId, intentId string) (string, error)

func GenerateSession

func GenerateSession(projectId, sessionId string) (string, error)

func JsonToWebhookRequest

func JsonToWebhookRequest(json []byte) (*dialogflow.WebhookRequest, error)

func JsonToWebhookResponse

func JsonToWebhookResponse(json []byte) (*dialogflow.WebhookResponse, error)

func ParseContext

func ParseContext(context string) (projectId, sessionId string, contextId string, err error)

func ParseIntent

func ParseIntent(intent string) (projectId, intentId string, err error)

func ParseSession

func ParseSession(session string) (projectId, sessionId string, err error)

func WebhookRequestToJson

func WebhookRequestToJson(req *dialogflow.WebhookRequest) ([]byte, error)

func WebhookResponseToJson

func WebhookResponseToJson(res *dialogflow.WebhookResponse) ([]byte, error)

Types

type DialogFlow

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

func (*DialogFlow) DetectIntent

func (df *DialogFlow) DetectIntent(ctx context.Context, req *Request) (*Response, error)

type Manager

type Manager interface {
	DetectIntent(ctx context.Context, req *Request) (*Response, error)
}

func NewManager

func NewManager(gcpjwt []byte) (Manager, error)

type Request

type Request struct {
	Message               string // required
	Username              string // required
	Language              string // optional <https://dialogflow.com/docs/languages>
	Timezone              string // optional <https://www.iana.org/time-zones>
	IntentContext         string // optional context
	IntentContextDeadline int32  // optional context lifespan count
	ResetContext          bool   // optional whether delete all contexts in the current session
}

func (*Request) Contexts

func (req *Request) Contexts(projectId string) []*dialogflowpb.Context

func (*Request) Session

func (req *Request) Session(projectId string) string

func (*Request) Validate

func (req *Request) Validate() bool

type Response

type Response struct {
	Intent     string
	Confidence float32
	Entities   map[string]*structpb.Value
	Response   string
}

func (*Response) GetEntity

func (res *Response) GetEntity(name string) interface{}

func (*Response) Set

func (res *Response) Set(result *dialogflowpb.DetectIntentResponse) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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