メインコンテンツへスキップ

Mattermost へ Incoming Webhook で投稿する

    FileMaker や cron などから簡単に Mattermost へ投稿できるように、Mattermost で Incoming Webhook を有効にしてみた。

    環境:WebARENA Indigo Linux 1GB(Ubuntu 22.04)、macOS Catalina Version 10.15.6(英語環境)

    (1)[Mattermost の左上メニュー>System Console>INTEGRATIONS>Integration Management>Enable Incoming Webhooks] が true にする(デフォルトでなっていた)。

    (2)[Mattermost の左上メニュー>Integrations>Incoming Webhooks] をクリック。

    [Add Incoming Webhook] をクリックし、詳細を記入する。[Lock to this channel] にチェックを入れなければ、チャンネルを限定せずに Incoming Webhook を利用できる。

    保存すると Incoming Webhook 用 URL が表示される。

    (3)[Mattermost の左上メニュー>System Console>INTEGRATIONS>Integration Management」で [Enable integrations to override usernames] と [Enable integrations to override profile picture icons] を true にすることで、アイコンや投稿者名を変更できるようになる。

    (4)このうえで、Mac の Terminal から以下のようなコマンドを実行すると、off-topic チャンネルに bot というユーザー名で simile アイコンで「あいうえお」という文章を投稿できる。

    $ curl -X POST -H "Content-Type: application/json" -d "{"username": "bot", "channel": "off-topic", "icon_emoji": ":smile:", "text": "あいうえお"}" [2の Webhook URL]

    メモ:
    ・チャンネル名はチャンネル URL に表示されている名前を使う。
    ・チャンネル名の指定は、頭に # などを付けても付けなくてもいい。
    ・投稿文に半角スペースが入っていても OK(Slack では NG だった)。
    ・アイコンとして使える絵文字は以下のサイトで探せばいい。

    Emoji cheat sheet for GitHub, Basecamp, Slack & more
    https://www.webfx.com/tools/emoji-cheat-sheet/

    参考:
    [Mattermost Integrations] Incoming WebHook 基本編
    https://zenn.dev/kaakaa/articles/qiita-20201202-b6c87ad68a1ad092532f

    [Mattermost Integrations] Incoming WebHook 発展編
    https://zenn.dev/kaakaa/articles/qiita-20201203-ed2e99a1b5383488c935