Ubidots Developer Guides
Help CenterAPI ReferenceData APICommunity
  • Welcome to our Dev Guides
  • ⚡️ Getting Started
    • What is Ubidots?
    • Devices, Variables, and Dots
    • Technical FAQs
    • Business FAQs
  • 🧩Integration Guides
    • Industrial IoT
      • Advantech
      • Amplified Engineering
      • AWS
      • Azimut
      • Balena
      • Bivocom
      • CESVA
      • Controllino
      • Digital Communications Technologies (DCT)
      • Everactive
      • Golioth
      • Kepware
      • Kunbus
      • Monnit
      • MultiTech
      • NCD.io
      • Node-RED
      • Omicron IoT
      • Red Lion
      • Robustel
      • Senquip
      • Sielco
      • Siemens
      • Strega
      • vNode
      • WAGO
      • Weintek
      • YuDash
    • Cellular
      • Blues Wireless
      • Digi International
      • Hologram
      • Monogoto
      • Particle
      • Quectel
      • Soracom
    • LoRaWAN
      • AonChip
      • Chirpstack
      • Decentlab
      • Helium
      • ioThings
      • LORIOT
      • Milesight
      • MOKOSmart
      • RAKwireless
      • Sagemcom
      • Seeed Studio
      • Senet
      • The Things Industries
        • The Things Stack
        • The Things Network
    • Sigfox
      • Digital Matter
      • McThings
      • Sigfox
      • Suntech
      • Thinxtra
      • UnaBiz
    • Satellite
      • Swarm
    • Dev Kits
      • Adafruit
      • Advantech
      • AloriumTech
      • Arduino
      • Blues Wireless
      • DFRobot
      • Dragino
      • Electric Imp
      • Espressif Systems
      • McThings
      • Microchip Technology
      • Onion
      • Particle
      • Pycom
      • RAKwireless
      • Raspberry Pi
      • Seeed Studio
      • Sodaq
      • STMicroelectronics
      • Texas Instruments
      • Thinxtra
      • Verse Technology
    • Weather
      • Weather Plugins
      • Ambient Weather
    • Tools
      • Gambit Communications
      • PubNub
  • 📊Dashboards & Widgets
    • HTML Canvas
      • 3rd party packages
      • Preload Dashboard data
      • Built-in library
        • Properties
        • Methods
        • Listening events
        • API
      • Examples
        • Basics
        • Create an LCD screen with the HTML Canvas
        • Interacting with dashboard data
        • Change header's custom style
        • Adding real time using Socket.IO
        • Delete Variable data from a Device
        • Delete Variable data from Groups or Types of Devices
        • Navigation through Dashboard
        • Using a React library
      • Code editor
        • HTML Tab
        • CSS Tab
        • JavaScript Tab
    • Custom UI
      • Paragraph
      • Input combo
        • Text
        • Numeric
        • Numeric with buttons
        • Date
        • Time
        • Toggle
        • Dropdown
        • Multiple selection dropdown
      • Button
    • Custom Style
      • Dashboards
      • Widgets
    • Line chart
    • Pages
      • Getting started
      • Development
      • API
        • Page creation
        • Publish
  • 🤖UbiFunctions
    • Getting Started
      • Creating an UbiFunction
      • Coding an UbiFunction
      • Testing an UbiFunction
      • Authentication
      • Execution Time
      • Logs
    • Runtimes
      • Python
      • NodeJS
      • Custom Runtimes
    • Invocation
      • Time-based Trigger
      • HTTPS
      • MQTT Publish
      • Ubidots Event
    • Advanced
      • Account Token
      • Execution time
      • Raw Functions
      • CORS Policy
      • Async Execution
      • DaaS (Decoder as a Service)
      • Developing and Managing UbiFunctions with Ubidots CLI
    • Examples
    • Specs and Limits
    • Storage
      • File Storage API
      • Mutiple files
  • 🧩Plugins
    • What is a plugin?
    • Public vs. Private
    • Public plugins
      • Cron
      • Webhook
    • Private Plugins
      • Cron
      • Webhook
      • Widget
      • Device
    • Plugins development
      • Getting started
      • Cron
      • Webhook
      • Widget
      • Device
      • view.xml
      • view_widget.xml
    • Plugins deployment
      • Cron and Webhook
      • Widget
      • Device
    • Using the plugins
      • Cron and Webhook
      • Widget
      • Device
  • 📈SYNTHETIC VARIABLES
    • Getting started
      • Creating synthetic variables
      • Synthetic Variables' editor
    • Expressions
      • Mathematical
      • Date range
      • Rolling
      • Special functions
    • Specs and limits
    • Examples
      • Mathematical
      • Date range
      • Rolling
      • Special functions
  • ⌨️Developer tools
    • Javascript SDK
      • Overview
      • Getting started
      • Ubidots class
        • Get methods
        • Filter methods
        • Ubidots objects
          • Entity object
          • Paginator
      • Examples
    • CLI
      • Overview
      • Installing
      • Usage
      • SDK for UbiFunctions
  • 🏗️Apps
    • App builder
      • Custom sidebar
Powered by GitBook
On this page
  • Topic structure
  • UbiFunction args
  • Certificates
  • Examples

Was this helpful?

Export as PDF
  1. UbiFunctions
  2. Invocation

MQTT Publish

PreviousHTTPSNextUbidots Event

Last updated 7 months ago

Was this helpful?

You can invoke an UbiFunction by publishing data through MQTT. This makes it possible to integrate devices and Gateways that may have a non-editable JSON payload that is not compatible with our or our .

Because our UbiFunctions MQTT Broker is shared across all functions, it is not possible to support subscribe requests and only the MQTT Publish method is accepted. Accordingly, all subscriptions requests will be rejected.

If you'd like to have a private MQTT Broker mapped to an UbiFunction, . In this case, subscribe actions can be supported.

The UbiFunction's method must be set to POST

Here are the MQTT settings needed to invoke an UbiFunction over the MQTT protocol:

MQTT Settings

Value

URL

functions.ubidots.com

Port

1883 for plain MQTT. 8883 for MQTT over TLS.

Topic

/prv/<your-username>/<function-label>

Username

Your account username

Password

Valid Token from your Ubidots account.

ClientID

Any random string. Preferably longer than 15 characters

Topic structure

To trigger an UbiFunction through MQTT, the publication topic must follow the structure:

/prv/<username>/<function-label>

Where:

  • <username> is your Ubidots account username.

  • <function-label> is the Name of the function but all lowercase and spaces replaced by dashes.

The base topic corresponds to the UbiFunction HTTPS Endpoint URL's path, as seen in the image below:

Advanced Topics

Additional topic levels are supported. To add more levels, simply add a forward slash ("/") after the base topic:

/prv/<username>/<function-label>/<level-1>/···/<level-N>

Where:

  • <level-N> is any additional UTF-8 encoded string that you want to add to the topic

Topics have the below limits:

Topic Limits

Limit

Length

1500 characters

Levels

10

UbiFunction args

When triggering an UbiFunction through the MQTT protocol, you'll receive a JSON object in the args variable of the main function. The JSON will have this structure:

{
  "topic": "<topic>",
  "payload": "<payload>",
  "from_client_id": "<client_id>",
}

Where:

Key

Type

Value description

topic

String

The multilevel publication topic

payload

String

The payload sent by the device in the publication message.

from_client_id

String

The client ID used in the MQTT connection.

Certificates

Ubidots supports SSL V1.1, TLS V1.2 and V1.3. You can download our root certificates in different formats:

Examples

mosquitto_pub \
-p 1883 \ 
-h functions.ubidots.com \
-t "/prv/<username>/<function-name>" \
-m '{"token": "TOKEN", "device": "device-label", "variable-label": value}' \
-u "<username>" \
-P "TOKEN" \
-q 1 -d
mosquitto_pub \
-p 8883 \ 
-h functions.ubidots.com \
-t "/prv/<username>/<function-name>" \
-m '{"token": "TOKEN", "device": "device-label", "variable-label": value}' \
-u "<username>" \
-P "TOKEN" \
-q 1 -d \
--cafile /Users/user/Documents/Ubidots/roots.pem

: Certificate chain with two root certificates from our certificate authorities (CAs).

: Same as the PEM file, with an alternative encoding.

: Same as the PEM file, with a different extension. Often referred to as .crt, .cert or .cer.

🤖
native MQTT broker
HTTP Data Ingestion API
please reach out to our sales team
PEM file
DER file
CRT file