Send message from Pico LTE to Slack

Send a message from the Pico LTE to a Slack channel through an incoming webhook, over the cellular connection.

This example sends a message from the Pico LTE to a Slack channel through an incoming webhook, over the cellular connection. No extra hardware is needed.

Before you begin

Required

Hardware

  • Sixfab Pico LTE or Pico LTE 2Registered and active in Sixfab Connect, connected to the computer with the micro USB cable.

Software

  • Thonny with MicroPython and the Pico LTE SDKSet up as in the quickstart.
  • config.jsonIn the root of the board: Prepare the configuration file.
  • Slack accountWith a workspace you can add an app to; the next section creates one if needed.

Create workspace

If you have a workspace to use, skip this section. Sign in to Slack and click Create a New Workspace, then:

  1. Enter company or team name.

  2. Add your name and profile photo.

  3. Add coworkers by email, or skip.

  4. Enter project your team works on.

    The workspace is created.

Create app

  1. Create new app.

    Open api.slack.com, click Your apps, then Create an app.

  2. Choose From scratch.

  3. Name app and choose workspace.

    For example PicoLTE, in the workspace that will receive the messages.

Add incoming webhook

  1. Activate incoming webhooks.

    In the app’s settings, open Incoming Webhooks under Features and turn the feature on.

  2. Add webhook to channel.

    Click Add New Webhook to Workspace and select the channel that will receive the messages.

  3. Copy webhook URL.

    The app appears in the channel, and Slack shows the webhook URL, specific to one user and one channel:

    https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX

Run example

  1. Set webhook URL in config.json.

    {
        "slack": {
            "webhook_url": "INCOMING_WEBHOOK_URL"
        }
    }
  2. Run script.

    Open examples/slack/send_message.py from the SDK repository in Thonny and click Run.

    INFO: Sending message to slack channel...
    INFO: Result: {'status': 0, 'response': ['ok'], 'interval': 0}
  3. Check channel.

    The message appears in the channel.