Chatter API

Access Salesforce Connect/Chatter for feeds, posts, and collaboration.

Get News Feed

Go
feed, err := client.Chatter().GetNewsFeed(ctx)
for _, item := range feed.Elements {
    fmt.Printf("%s: %s\n", item.Actor.Name, item.Body.Text)
}

Post to Feed

Go
post, err := client.Chatter().PostFeedElement(ctx, connect.FeedInput{
    SubjectId: "me",  // or user/group/record ID
    Body: connect.MessageBodyInput{
        MessageSegments: []connect.MessageSegmentInput{
            {Type: "Text", Text: "Hello from Go SDK!"},
        },
    },
})

Post Comment

Go
comment, _ := client.Chatter().PostComment(ctx, feedElementId, "Great post!")

Like a Post

Go
client.Chatter().LikeFeedElement(ctx, feedElementId)

User Profile

Go
// Get current user
me, _ := client.Chatter().GetCurrentUser(ctx)
fmt.Println("Welcome,", me.Name)

// Get any user
user, _ := client.Chatter().GetUser(ctx, userId)

Available Methods

Method Description
GetNewsFeed() Get news feed
GetRecordFeed() Get record feed
PostFeedElement() Create a post
PostComment() Comment on post
LikeFeedElement() Like a post
GetCurrentUser() Get current user
GetUser() Get user profile
GetGroups() List groups
GetFiles() Get user files