DEV Community

Cover image for Play With Mattermost
Zex
Zex

Posted on

3 1

Play With Mattermost

Mattermost provides a series of API to interact with the server.

Let's create a service to post Mattermost message daily if we have new orders.

The new order message contains a plaintext message and an Excel file, which is generated by the service as well.

The message contains Emoji, just include them as plaintext.

We have new orders today!! πŸ‘πŸ‘

msg := "We have new orders today!! :clap::clap:"

Upload the file first so that the post can include it by adding the file ID. data is the file content.

frsp, rsp := cli.UploadFile(data, chann_id, fd.Name())

Great! Now the file IDs are in frsp, which is a FileUploadResponse. Extract them and save in file_ids.

  post, rsp := cli.CreatePost(&mm.Post{
    FileIds: file_ids,
    ChannelId: chann_id,
    Message: msg,
  })

Then we have a new post on the channel with chann_id, members on that channel can see it. :D

See also

Sentry image

See why 4M developers consider Sentry, β€œnot bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay