Slack.message() isn't working

Issue description

I’m using InfluxCloud and want to set up a Task that periodically monitors my data and alerts to a Slack channel. However, I’m having trouble getting the slack.message() function to function. I cannot use it with my own webhook, and it even fails on the example code.

Steps to reproduce

Create an InfluxCloud account. Copy the example code for the slack.message() function into a new Task (the Task options don’t matter as we’ll invoke it manually):

import "slack"

option task = { 
  name: "slack-test",
  every: 1h,
}

slack.message(
  url: "https://slack.com/api/chat.postMessage",
  token: "mySuPerSecRetTokEn",
  username: "Fluxtastic",
  channel: "#flux",
  workspace: "",
  text: "This is a message from the Flux slack.message() function.",
  iconEmoji: "wave",
  color: "good"
)

Invoke the task manually and check its run logs.

Expected output:

Authentication errors.

Actual output:

Error exhausting result iterator; Err: type error @7:1-16:2: missing required argument iconEmoji: type error @7:1-16:2: missing required argument iconEmoji

Note that the iconEmoji argument ("wave") is passed, in fact. I’m getting the same errors if I provide the function with a correct Webhook URL.

I was able to get Slack notifications working by using the example from slack.endpoint() instead:

import "slack"
import "influxdata/influxdb/secrets"

token = secrets.get(key: "SLACK_TOKEN")
e = slack.endpoint(token: token)

crit_statuses = from(bucket: "example-bucket")
  |> range(start: -1m)
  |> filter(fn: (r) => r._measurement == "statuses" and status == "crit")

crit_statuses
  |> e(mapFn: (r) => ({
      username: r.username,
      channel: r.channel,
      workspace: r.workspace,
      text: r.text,
      iconEmoji: r.iconEmoji,
      color: r.color,
    })
  )()

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.