docs-v2/content/influxdb/v2.0/reference/flux/stdlib/contrib/webexteams/message.md

2.1 KiB

title description menu weight
webexteams.message() function The `webexteams.message()` function sends a single message to Webex using the [Webex messages API](https://developer.webex.com/docs/api/v1/messages/create-a-message).
influxdb_2_0_ref
name parent
webexteams.message Webex Teams
202

The webexteams.message() function sends a single message to Webex using the Webex messages API.

import "contrib/sranka/webexteams"

webexteams.message(,
  url: "https://webexapis.com"
  token: "My5uP3rs3cRe7T0k3n",
  roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0",
  text: "Example plain text message",
  markdown: "Example [markdown message](https://developer.webex.com/docs/api/basics)." 
)

Parameters

url

Base URL of Webex API endpoint (without a trailing slash). Default is https://webexapis.com.

Data type: String

token

({{< req >}}) Webex API access token.

Data type: String

roomId

({{< req >}}) Room ID to send the message to.

Data type: String

text

({{< req >}}) Plain text message.

Data type: String

markdown

({{< req >}}) Markdown formatted message.

Data type: String

Examples

Send the last reported status to Webex Teams
import "contrib/sranka/webexteams"
import "influxdata/influxdb/secrets"

apiToken = secrets.get(key: "WEBEX_API_TOKEN")

lastReported =
  from(bucket: "example-bucket")
    |> range(start: -1m)
    |> filter(fn: (r) => r._measurement == "statuses")
    |> last()
    |> findRecord(fn: (key) => true, idx: 0)

webexteams.message(
  token: apiToken,
  roomId: "Y2lzY29zcGFyazovL3VzL1JPT00vYmJjZWIxYWQtNDNmMS0zYjU4LTkxNDctZjE0YmIwYzRkMTU0",
  text: "Disk usage is ${lastReported.status}.",
  markdown: "Disk usage is **${lastReported.status}**."
)