activity

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 License: MIT Imports: 7 Imported by: 14

Documentation

Overview

Package activity acts as a handler for any received activity and the user defined operation on that activity. It then is responsible for sending a reply to the connector service.

Index

Constants

View Source
const (
	// APIVersion for response URLs
	APIVersion = "v3"
)

Variables

This section is empty.

Functions

func ApplyConversationReference added in v0.2.0

func ApplyConversationReference(activity schema.Activity, reference schema.ConversationReference, isIncoming bool) schema.Activity

ApplyConversationReference sets delivery information to the activity from conversation reference

func GetCoversationReference added in v0.2.0

func GetCoversationReference(activity schema.Activity) schema.ConversationReference

GetCoversationReference returns conversation reference from the activity

func PrepareActivityContext

func PrepareActivityContext(handler Handler, context *TurnContext) (schema.Activity, error)

PrepareActivityContext routes the received Activity to respective handler function. Returns the result of the handler function.

Types

type DefaultResponse

type DefaultResponse struct {
	Client client.Client
}

DefaultResponse is the default implementation of Response.

func (*DefaultResponse) DeleteActivity added in v0.2.1

func (response *DefaultResponse) DeleteActivity(activity schema.Activity) error

DeleteActivity sends a Delete activity method to the BOT connector service.

func (*DefaultResponse) SendActivity

func (response *DefaultResponse) SendActivity(activity schema.Activity) error

SendActivity sends an activity to the BOT connector service.

func (*DefaultResponse) UpdateActivity added in v0.2.3

func (response *DefaultResponse) UpdateActivity(activity schema.Activity) error

UpdateActivity sends a Put activity method to the BOT connector service.

type Handler

type Handler interface {
	OnMessage(context *TurnContext) (schema.Activity, error)
	OnInvoke(context *TurnContext) (schema.Activity, error)
	OnConversationUpdate(context *TurnContext) (schema.Activity, error)
}

Handler acts as the interface for the client program to define actions on various events from connector service.

type HandlerFuncs

type HandlerFuncs struct {
	OnMessageFunc            func(turn *TurnContext) (schema.Activity, error)
	OnInvokeFunc             func(turn *TurnContext) (schema.Activity, error)
	OnConversationUpdateFunc func(turn *TurnContext) (schema.Activity, error)
}

HandlerFuncs is an adaptor to let client program specify as many or as few functions to handle events of the connector service while still implementing Handler.

func (HandlerFuncs) OnConversationUpdate added in v0.2.1

func (r HandlerFuncs) OnConversationUpdate(turn *TurnContext) (schema.Activity, error)

OnConversationUpdate handles a 'conversationUpdate' event from connector service.

func (HandlerFuncs) OnInvoke added in v0.2.0

func (r HandlerFuncs) OnInvoke(turn *TurnContext) (schema.Activity, error)

OnInvoke handles a 'invoke' event from connector service.

func (HandlerFuncs) OnMessage

func (r HandlerFuncs) OnMessage(turn *TurnContext) (schema.Activity, error)

OnMessage handles a 'message' event from connector service.

type MsgOption added in v0.2.0

type MsgOption func(*schema.Activity) error

MsgOption option provided when sending an activity.

func MsgOptionAttachments added in v0.2.0

func MsgOptionAttachments(attachments []schema.Attachment) MsgOption

MsgOptionAttachments adds attachment to the activity.

func MsgOptionText added in v0.2.0

func MsgOptionText(text string) MsgOption

MsgOptionText adds text to the activity.

type Response

type Response interface {
	SendActivity(activity schema.Activity) error
	DeleteActivity(activity schema.Activity) error
	UpdateActivity(activity schema.Activity) error
}

Response provides functionalities to send activity to the connector service.

func NewActivityResponse

func NewActivityResponse(connectorClient client.Client) (Response, error)

NewActivityResponse provides a DefaultResponse implementaton of Response.

type TurnContext

type TurnContext struct {
	Activity schema.Activity
}

TurnContext wraps the Activity received and provides operations for the user program of this SDK.

The return value is Activity as provided by the client program, to be send to the connector service.

func (*TurnContext) SendActivity added in v0.2.0

func (t *TurnContext) SendActivity(options ...MsgOption) (schema.Activity, error)

SendActivity sends an activity to user. TODO: Change comment

Jump to

Keyboard shortcuts

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