msteams

package module
v0.0.0-...-3395af6 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

README

GoDoc

msteams-go-webhook

Go Lang library to send messages to MSTeams via Incoming Webhooks.

Usage

package main

import "github.com/ykorzikowski/msteams-go-webhook"
import "fmt"

func main() {
    webhookUrl := "https://hooks.slack.com/services/foo/bar/baz"

    section1 := msteams.Section {
      ActivityTitle: "![TestImage](https://47a92947.ngrok.io/Content/Images/default.png)Larry Bryant created a new task",
      ActivitySubTitle: "On Project Tango",
      ActivityImage: "https://teamsnodesample.azurewebsites.net/static/img/image5.png",
      Markdown: true
    }
    section1.AddFact(msteams.Fact { Name: "Assigned To", Value: "Unassigned" })

    potentialAction1 := msteams.PotentialAction {
      Type: "ActionCard",
      Name: "Add a comment",
    }
    potentialAction1.AddInput ( msteams.Input {Type: "TextInput", Id: "comment", IsMultiline: false, Title: "Add a comment here for this task"})
    potentialAction1.AddAction( msteams.Action {Type: "HttpPOST", Name: "Add comment", Target: "http://..."})

    payload := msteams.Payload {
      Type: "MessageCard",
      Context: "http://schema.org/extensions",
      ThemeColor: "0076D7",
      Summary: "Larry Bryant created a new task",
      Sections: []msteams.Section{section1},
      PotentialActions: []msteams.PotentialAction{potentialAction1},
    }

    err := msteams.Send(webhookUrl, "", payload)
    if len(err) > 0 {
      fmt.Printf("error: %s\n", err)
    }
}

License

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0

Reference used

https://github.com/ashwanthkumar/slack-go-webhook

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Send

func Send(webhookUrl string, proxy string, payload Payload) []error

Types

type Action

type Action struct {
	Type string `json:"@type"`
	Name string `json:"name"`
	Url  string `json:"target"`
}

type Fact

type Fact struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Input

type Input struct {
	Type        string `json:"@type"`
	Id          string `json:"id"`
	IsMultiline bool   `json:"isMultiline"`
	Title       string `json:"title"`
}

type Payload

type Payload struct {
	Type             string            `json:"@type"`
	Context          string            `json:"@context"`
	ThemeColor       string            `json:"themeColor"`
	Summary          string            `json:"summary"`
	Sections         []Section         `json:"sections"`
	PotentialActions []PotentialAction `json:"potentialAction"`
}

type PotentialAction

type PotentialAction struct {
	Type    *string   `json:"@type"`
	Name    *string   `json:"name"`
	Inputs  []*Input  `json:"inputs"`
	Actions []*Action `json:"inputs"`
}

func (*PotentialAction) AddAction

func (potentialAction *PotentialAction) AddAction(action Action) *PotentialAction

func (*PotentialAction) AddInput

func (potentialAction *PotentialAction) AddInput(input Input) *PotentialAction

type Section

type Section struct {
	ActivityTitle    *string `json:"activityTitle"`
	ActivitySubTitle *string `json:"activitySubTitle"`
	ActivityImage    *string `json:"activityImage"`
	Facts            []*Fact `json:"facts,omitempty"`
	Markdown         *bool   `json:"markdown"`
}

func (*Section) AddFact

func (section *Section) AddFact(fact Fact) *Section

Jump to

Keyboard shortcuts

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