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

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay