Documentation
¶
Overview ¶
Package teams provides a Messenger adapter for Microsoft Teams using the Bot Framework protocol for bi-directional communication.
The adapter wraps github.com/infracloudio/msbotbuilder-go and exposes an HTTP endpoint that receives Bot Framework activities. Outgoing messages are sent as proactive messages through the Bot Framework REST API.
Transport: HTTP webhook (public endpoint required).
Authentication ¶
A Bot Framework App ID and App Password are required. These are obtained from the Azure Bot registration portal.
Usage ¶
m, err := teams.New(teams.Config{
AppID: os.Getenv("TEAMS_APP_ID"),
AppPassword: os.Getenv("TEAMS_APP_PASSWORD"),
ListenAddr: ":3978",
})
if err != nil { /* handle */ }
if err := m.Connect(ctx); err != nil { /* handle */ }
defer m.Disconnect(ctx)
Index ¶
- type Config
- type Messenger
- func (m *Messenger) Connect(ctx context.Context) (http.Handler, error)
- func (m *Messenger) ConnectionInfo() string
- func (m *Messenger) Disconnect(ctx context.Context) error
- func (m *Messenger) FormatApproval(req messenger.SendRequest, info messenger.ApprovalInfo) messenger.SendRequest
- func (m *Messenger) FormatClarification(req messenger.SendRequest, info messenger.ClarificationInfo) messenger.SendRequest
- func (m *Messenger) Platform() messenger.Platform
- func (m *Messenger) Receive(_ context.Context) (<-chan messenger.IncomingMessage, error)
- func (m *Messenger) Send(ctx context.Context, req messenger.SendRequest) (messenger.SendResponse, error)
- func (m *Messenger) UpdateMessage(_ context.Context, _ messenger.UpdateRequest) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// AppID is the Microsoft Bot Framework App ID.
AppID string
// AppPassword is the Microsoft Bot Framework App Password.
AppPassword string
// ListenAddr is the address to listen on for incoming activities (e.g., ":3978").
ListenAddr string
}
Config holds Teams-specific configuration.
type Messenger ¶
type Messenger struct {
// contains filtered or unexported fields
}
Messenger implements the messenger.Messenger interface for Microsoft Teams. It provides an HTTP handler for receiving Bot Framework activities and uses the adapter to send proactive messages. The caller is responsible for mounting the handler on a shared HTTP mux.
func (*Messenger) Connect ¶
Connect initializes the Teams Bot Framework adapter and returns an http.Handler for receiving Bot Framework activities. The caller mounts this handler on a shared HTTP mux at the desired context path (e.g., /agents/{name}/teams/events).
The adapter DOES NOT start its own http.Server.
func (*Messenger) ConnectionInfo ¶
ConnectionInfo returns connection instructions for the Teams adapter.
func (*Messenger) Disconnect ¶
Disconnect gracefully shuts down the Teams adapter.
func (*Messenger) FormatApproval ¶
func (m *Messenger) FormatApproval(req messenger.SendRequest, info messenger.ApprovalInfo) messenger.SendRequest
FormatApproval builds a Microsoft Teams Adaptive Card for an approval notification. This satisfies the messenger.ApprovalFormatter interface, keeping all Teams-specific formatting inside the adapter.
func (*Messenger) FormatClarification ¶
func (m *Messenger) FormatClarification(req messenger.SendRequest, info messenger.ClarificationInfo) messenger.SendRequest
FormatClarification builds a Teams Adaptive Card for a clarification question.
func (*Messenger) Send ¶
func (m *Messenger) Send(ctx context.Context, req messenger.SendRequest) (messenger.SendResponse, error)
Send delivers a message to a Teams conversation. If req.Metadata["attachments"] contains a []schema.Attachment, the message is sent with Adaptive Card formatting (the text field is used as the plaintext fallback).
func (*Messenger) UpdateMessage ¶
UpdateMessage is a no-op for Teams — the adapter does not currently support editing previously sent messages. Returns nil to satisfy the Messenger interface without error. Teams Adaptive Card updates will be added incrementally.