How to make published data be carried as payload into a slack webhook?

i would like to take some sensor data up to slack notifications.
i don’t understand how to make a reference to it in the webhook.json file.

You’ve got to use {{SPARK_EVENT_VALUE}} in your JSON File.

I put together this JSON from the examples of the webhooks documentation (http://docs.spark.io/webhooks)

 {
    "eventName": "slack",
    "url": " …here goes your slack url… ",
    "requestType": "POST",
    "access_token": " …here goes your access token…",
    "json":
    {
      "channel": "#channel",
		  "username": "SparkBot",
		  "text": "{{SPARK_EVENT_VALUE}}",
		  "icon_emoji": ":spark:"
    },
    "mydevices": true
}

You can trigger it by:

Spark.publish("slack", String(value));
2 Likes