microsoft_teams

package
v0.0.0-...-53546a6 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BasicMessageTemplate = []byte(`{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.6",
	"body": [
		{
			"type":   "TextBlock",
			"size":   "Large",
			"weight": "Bolder",
			"text":   "{{.Title}}",
			"spacing": "Small",
			"horizontalAlignment":      "Left",
			"verticalContentAlignment": "Center"
		},
		{
			"type":   "TextBlock",
			"text":   "{{.Description}}",
			"wrap": true,
			"spacing": "Small",
			"horizontalAlignment":      "Left",
			"verticalContentAlignment": "Center"
		},
		{
			"type": "FactSet",
			"facts": {{.Facts}}
		}
	],
	"actions": [
		{
			"type":  "Action.OpenUrl",
			"title": "{{.ActionTitle}}",
			"url":   "{{.ActionURL}}"
		}
	]
  }`)
View Source
var BotMessagesHandler = activity.HandlerFuncs{
	OnMessageFunc: func(turn *activity.TurnContext) (schema.Activity, error) {
		if strings.EqualFold(turn.Activity.Text, "ping") {
			return turn.SendActivity(activity.MsgOptionText("POOONGGGG!!!!!!!!!!!!!"))
		}
		return schema.Activity{}, nil
	},

	OnConversationUpdateFunc: func(turn *activity.TurnContext) (schema.Activity, error) {
		if len(turn.Activity.MembersRemoved) > 0 {
			for _, memberRemoved := range turn.Activity.MembersRemoved {
				if memberRemoved.ID == turn.Activity.Recipient.ID {

					return turn.SendActivity(activity.MsgOptionText("highlight.io bot uninstalled successfully!"))
				}
			}
		}

		if len(turn.Activity.MembersAdded) > 0 {

			for _, member := range turn.Activity.MembersAdded {

				if member.ID == turn.Activity.Recipient.ID {
					return turn.SendActivity(activity.MsgOptionText("👋 Your highlight.io notifications bot has been installed successfully. You can now set a Teams channel as recipient for your alerts."))
				}
			}
		}

		return schema.Activity{}, nil
	},
}
View Source
var ErrorAlertMessageTemplate = []byte(`{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.6",
	"body": [
	  {
		"type": "Container",
		"style": "{{.ContainerStyle}}",
		"items": [
		  {
			"type": "TextBlock",
			"size": "Large",
			"weight": "Bolder",
			"text": "{{.Title}}",
			"spacing": "Small",
			"horizontalAlignment": "Left",
			"verticalContentAlignment": "Center"
		  },
		  {
			"type": "TextBlock",
			"text": "{{.Description}}",
			"wrap": true,
			"spacing": "Small",
			"horizontalAlignment": "Left",
			"verticalContentAlignment": "Center"
		  },
		  {
			"type": "FactSet",
			"facts": {{.Facts}}
		  },
		  {
			"type": "Container",
			"items": [
			  {
				"type": "ColumnSet",
				"columns": [
				  {
					"type": "Column",
					"width": "stretch",
					"items": [
					  {
						"type": "ActionSet",
						"actions": [
						  {
							"type": "Action.OpenUrl",
							"title": "{{.SessionLabel}}",
							"url": "{{.SessionURL}}",
							"isEnabled": {{.DisplayMissingSessionLabel}}
						  },
						  {
							"type": "Action.OpenUrl",
							"title": "View Error",
							"url": "{{.ErrorURL}}"
						  }
						]
					  }
					]
				  }
				]
			  }
			]
		  },
		  {
			"type": "Container",
			"items": [
			  {
				"type": "ColumnSet",
				"columns": [
				  {
					"type": "Column",
					"width": "stretch",
					"items": [
					  {
						"type": "ActionSet",
						"actions": [
						  {
							"type": "Action.OpenUrl",
							"title": "Resolve Error",
							"url": "{{.ErrorResolveURL}}"
						  },
						  {
							"type": "Action.OpenUrl",
							"title": "Ignore Error",
							"url": "{{.ErrorIgnoreURL}}"
						  },
						  {
							"type": "Action.OpenUrl",
							"title": "Snooze Error",
							"url": "{{.ErrorSnoozeURL}}"
						  }
						]
					  }
					]
				  }
				]
			  }
			]
		  }
		]
	  }
	]
  }`)
View Source
var (
	MicrosoftGraphUrl = "https://graph.microsoft.com/v1.0"
)
View Source
var NewSessionAlertMessageTemplate = []byte(`{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.6",
	"body": [
		{{ if .AvatarURL }}
			{
				"type": "ColumnSet",
				"columns": [
					{
						"type": "Column",
						"items": [
							{
								"type": "Image",
								"url": "{{.AvatarURL}}",
								"size": "Small",
								"style": "Person"
							}
						],
						"width": "auto"
					},
					{
						"type": "Column",
						"items": [
							{
								"type":   "TextBlock",
								"size":   "Large",
								"weight": "Bolder",
								"text":   "{{.Title}}",
								"width":                    "stretch",
								"spacing":                  "Small",
								"horizontalAlignment":      "Left",
								"verticalContentAlignment": "Center"
							}
						]
					}
				]
			},
		{{else}}
			{
				"type":   "TextBlock",
				"size":   "Large",
				"weight": "Bolder",
				"text":   "{{.Title}}"
			},
		{{end}}
		{
			"type":   "TextBlock",
			"text":   "{{.UserIdentifier}}"
		},
		{
			"type": "FactSet",
			"facts": {{.Facts}}
				  
		}
	],
	"actions": [
		{
			"type":  "Action.OpenUrl",
			"title": "View Session",
			"url":   "{{.SessionURL}}"
		}
	]
  }`)
View Source
var TrackPropertiesTemplate = []byte(`{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.6",
	"body": [
		{
			"type":   "TextBlock",
			"size":   "Large",
			"weight": "Bolder",
			"text":   "{{.Title}}"
		},
		{
			"type":   "TextBlock",
			"text":   "{{.Description}}"
		},
		{
			"type": "ColumnSet",
			"columns": [
				{
					"type": "Column",
					"items": [
						{
							"type":   "TextBlock",
							"size":   "Medium",
							"weight": "Bolder",
							"text":   "Matched Track Properties"
						},
						{
							"type":   "TextBlock",
							"text":   "{{.MatchedValues}}",
							"wrap":    true,
							"width":   "stretch",
							"spacing": "Small"
						}
					]
				}
			]
		}
		{{ if .RelatedValues }}
			,{
				"type": "ColumnSet",
				"columns": [
					{
						"type": "Column",
						"items": [
							{
								"type":   "TextBlock",
								"size":   "Large",
								"weight": "Bolder",
								"text":   "Matched Track Properties"
							},
							{
								"type":   "TextBlock",
								"text":   "{{.RelatedValues}}",
								"wrap": true,
								"width":                    "stretch",
								"spacing":                  "Small"
							}
						]
					}
				]
			}
		{{end}}
	]
  }`)
View Source
var UserPropertiesTemplate = []byte(`{
	"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
	"type": "AdaptiveCard",
	"version": "1.6",
	"body": [
		{
			"type":   "TextBlock",
			"size":   "Large",
			"weight": "Bolder",
			"text":   "{{.Title}}"
		},
		{
			"type":   "TextBlock",
			"text":   "{{.Description}}"
		},
		{
			"type": "ColumnSet",
			"columns": [
				{
					"type": "Column",
					"items": [
						{
							"type":   "TextBlock",
							"size":   "Large",
							"weight": "Bolder",
							"text":   "Matched Track Properties"
						},
						{
							"type":   "TextBlock",
							"text":   "{{.MatchedUserProperties}}",
							"wrap":    true,
							"width":   "stretch",
							"spacing": "Small"
						}
					]
				}
			]
		}
	],
	"actions": [
		{
			"type":  "Action.OpenUrl",
			"title": "{{.ActionTitle}}",
			"url":   "{{.ActionURL}}"
		}
	]
}`)

Functions

func GQLInputToGo

func GQLInputToGo(microsoftTeamsChannels []*modelInputs.MicrosoftTeamsChannelInput) []*model.MicrosoftTeamsChannel

func GetAadGroupIDFromActivity

func GetAadGroupIDFromActivity(activity schema.Activity) string

func GetAccessToken

func GetAccessToken(ctx context.Context, tenantID string) (*oauth2.Token, error)

func GetChannelSuggestions

func GetChannelSuggestions(workspace *model.Workspace) ([]*model.MicrosoftTeamsChannel, error)

func GetChannels

func GetChannels(tenantID string, teamResponse TeamResponse) ([]*model.MicrosoftTeamsChannel, error)

func GetOAuthConfigForTenant

func GetOAuthConfigForTenant(tenantID string) (*oauth2.Config, []oauth2.AuthCodeOption, error)

func MakeAdaptiveCard

func MakeAdaptiveCard(templateString []byte, payload interface{}) (map[string]interface{}, error)

func SendLogAlertsWelcomeMessage

func SendLogAlertsWelcomeMessage(ctx context.Context, alert *model.LogAlert, input *WelcomeMessageData) error

Types

type BasicTemplatePayload

type BasicTemplatePayload struct {
	Title       string
	ActionTitle string
	ActionURL   string
	Description string
	Facts       string
}

type BotAdapter

type BotAdapter struct {
	Adapter core.Adapter
	BotID   string
}

type ChannelResponse

type ChannelResponse struct {
	OdataId             string `json:"@odata.id"`
	ID                  string `json:"id"`
	CreatedDateTime     string `json:"createdDateTime"`
	DisplayName         string `json:"displayName"`
	Description         string `json:"description"`
	IsFavoriteByDefault bool   `json:"isFavoriteByDefault"`
	Email               string `json:"email"`
	TenantID            string `json:"tenantId"`
	WebUrl              string `json:"webUrl"`
	MembershipType      string `json:"membershipType"`
}

type ErrorAlertTemplatePayload

type ErrorAlertTemplatePayload struct {
	Title                      string
	Description                string
	Facts                      string
	SessionLabel               string
	SessionURL                 string
	ErrorURL                   string
	ErrorResolveURL            string
	ErrorIgnoreURL             string
	ErrorSnoozeURL             string
	ContainerStyle             string
	DisplayMissingSessionLabel bool
}

type Fact

type Fact struct {
	Title string `json:"title"`
	Value string `json:"value"`
}

type GraphResponse

type GraphResponse[T any] struct {
	Context string `json:"@odata.context"`
	Count   int    `json:"@odata.count"`
	Value   []T    `json:"value"`
}

type MicrosoftTeamsBot

type MicrosoftTeamsBot struct {
	core.Adapter
	TenantID string
	BotID    string
}

func NewMicrosoftTeamsBot

func NewMicrosoftTeamsBot(tenantID string) (*MicrosoftTeamsBot, error)

func (*MicrosoftTeamsBot) SendErrorAlert

func (bot *MicrosoftTeamsBot) SendErrorAlert(channelId string, payload integrations.ErrorAlertPayload) error

func (*MicrosoftTeamsBot) SendErrorFeedbackAlert

func (bot *MicrosoftTeamsBot) SendErrorFeedbackAlert(channelId string, payload integrations.ErrorFeedbackAlertPayload) error

func (*MicrosoftTeamsBot) SendLogAlert

func (bot *MicrosoftTeamsBot) SendLogAlert(channelId string, payload integrations.LogAlertPayload) error

func (*MicrosoftTeamsBot) SendMessageWithAdaptiveCard

func (bot *MicrosoftTeamsBot) SendMessageWithAdaptiveCard(channelId string, rawTemplate []byte, templateData interface{}) error

func (*MicrosoftTeamsBot) SendMetricMonitorAlert

func (bot *MicrosoftTeamsBot) SendMetricMonitorAlert(channelId string, payload integrations.MetricMonitorAlertPayload) error

func (*MicrosoftTeamsBot) SendNewSessionAlert

func (bot *MicrosoftTeamsBot) SendNewSessionAlert(channelId string, payload integrations.NewSessionAlertPayload) error

func (*MicrosoftTeamsBot) SendNewUserAlert

func (bot *MicrosoftTeamsBot) SendNewUserAlert(channelId string, payload integrations.NewUserAlertPayload) error

func (*MicrosoftTeamsBot) SendRageClicksAlert

func (bot *MicrosoftTeamsBot) SendRageClicksAlert(channelId string, payload integrations.RageClicksAlertPayload) error

func (*MicrosoftTeamsBot) SendTrackPropertiesAlert

func (bot *MicrosoftTeamsBot) SendTrackPropertiesAlert(channelId string, payload integrations.TrackPropertiesAlertPayload) error

func (*MicrosoftTeamsBot) SendUserPropertiesAlert

func (bot *MicrosoftTeamsBot) SendUserPropertiesAlert(channelId string, payload integrations.UserPropertiesAlertPayload) error

type NewSessionAlertPayload

type NewSessionAlertPayload struct {
	Title          string
	SessionURL     string
	UserIdentifier string
	AvatarURL      string
	Facts          string
}

type TeamResponse

type TeamResponse struct {
	OdataId     string `json:"@odata.id"`
	ID          string `json:"id"`
	DisplayName string `json:"displayName"`
	Description string `json:"description"`
}

func GetTeamsFromWorkspace

func GetTeamsFromWorkspace(workspace *model.Workspace) ([]TeamResponse, error)

type TeamsApp

type TeamsApp struct {
	Id         string `json:"id"`
	ExternalId string `json:"externalId"`
}

type TeamsAppResponse

type TeamsAppResponse struct {
	ID       string   `json:"id"`
	TeamsApp TeamsApp `json:"teamsApp"`
}

type WelcomeMessageData

type WelcomeMessageData struct {
	Workspace     *model.Workspace
	Admin         *model.Admin
	Project       *model.Project
	OperationName string
}

Jump to

Keyboard shortcuts

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