package main import ( "fmt" "github.com/slack-go/slack" ) func main() { api := slack.New("YOUR_TOKEN_HERE") attachment := slack.Attachment{ Pretext: "some pretext", Text: "some text", // Uncomment the following part to send a field too /* Fields: []slack.AttachmentField{ slack.AttachmentField{ Title: "a", Value: "no", }, }, */ } channelID, timestamp, err := api.PostMessage( "CHANNEL_ID", slack.MsgOptionText("Some text", false), slack.MsgOptionAttachments(attachment), slack.MsgOptionAsUser(true), // Add this if you want that the bot would post message as a user, otherwise it will send response using the default slackbot ) if err != nil { fmt.Printf("%s\n", err) return } fmt.Printf("Message successfully sent to channel %s at %s", channelID, timestamp) }