Difference between revisions of "Trigger: Webhook (URL)"

 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<pre style="background-color: #EEEEEE; color: Black; border-radius: 10px; padding: 10px;">
+
<pre class="header-style">This trigger will fire on this device when the specified web URL is called from anywhere. The webhook uses Firebase Cloud Messaging to deliver notifications to your device, enabling remote triggering of macros from any device or service that can make HTTP requests.</pre>
This trigger will fire on this device when the specified web URL is called from anywhere.
 
  
WARNING:
+
''' Options '''
  
that the URL is unique to this device and the URL will change if the application is reinstalled (or all application data is deleted).
+
* '''Identifier''': Custom text appended to your webhook URL (e.g., "mywebhook" creates https://trigger.macrodroid.com/[device-id]/mywebhook)
 +
* '''IP Address Whitelist''': Restrict which IP addresses can trigger the webhook (supports wildcards and Magic Text)
 +
* '''Variable Whitelist''': Enable to restrict which variables can be updated via webhook parameters
 +
* '''Save Body to Variable''': Save the HTTP POST request body to a string variable (max 3800 characters)
  
This feature uses Firebase Cloud Messaging to notify the device via the backend server, therefore it is not functional on devices that lack Google services (such as Alexa tablets etc.)
+
''' URL Format '''
  
SENDING PARAMETERS:
+
Your webhook URL follows this format:
 +
<pre>https://trigger.macrodroid.com/[device-id]/[identifier]</pre>
  
In addition to an identifier it is also possible to send URL parameters to the trigger which are then used to set MacroDroid Variables. The format for sending parameters is as follows:
+
''' Passing Variables '''
  
PARAMETERS OF EXAMPLES:
+
Variables can be passed via URL query parameters:
  
ID = User-defined identifier.
+
* '''Single variable''': <code>?VARNAME=value</code>
 +
* '''Multiple variables''': <code>?VARNAME1=42&VARNAME2=text</code>
 +
* '''Dictionary/Array values''': <code>?mydict(KEY)=VALUE</code> or <code>?mydict(KEY1)(KEY2)=VALUE</code>
  
VARNAME1 = The first variable to be defined, in this case with a numerical value.
+
Supported variable types: String, Integer, Decimal, Boolean
  
VARNAME2 = The second variable to be defined, in this case with a plain-text value
+
''' Device ID Management '''
  
DATA = Dictionary.
+
* '''Export Device ID''': Share your device ID with password protection to port to a new device
 +
* '''Import Device ID''': Import a previously exported device ID to maintain existing webhook URLs
 +
* '''Generate New Device ID''': Create a new device ID (invalidates all existing webhook URLs)
 +
* '''Refresh Cloud Token''': Re-upload the Firebase Cloud Messaging token to resolve connection issues
  
(KEY) = The key you are defining in your Dictionary / Array.
+
''' TinyURL Integration '''
  
= After this sign goes the value you want to send in the webhook.
+
Generate a shortened URL via TinyURL for easier sharing. The shortened URL format is:
 +
<pre>[tinyurl]/[identifier]</pre>
  
To set a variable:
+
''' Local Variables '''
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=Hello
 
  
To set multiple variables:
+
Magic text variables available with this trigger include:
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=42&VARNAME2=Hello_World
+
* Webhook request IP address
 +
* Query parameters
  
For Dictionaries / Array:
+
''' Examples '''
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?DATA(KEY)=VALUETEXT
 
  
</pre>
+
  <pre class="trigger-style">Triggers
More information here.
 
https://medium.com/@macrodroid/introducing-the-webhook-trigger-a760e2ee140d
 
  
'''Example Usage'''<br/>
+
Webhook (URL): lights_on</pre>
This macro will receive values by webhook and speak them by TTS.
+
  <pre class="action-style">Actions
<pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
 
Triggers
 
  
Webhook (MyWebhook)
+
Send Intent: Turn on smart lights
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=Hello
+
Notification: Lights turned on via webhook</pre>
</pre><br>
 
<pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
 
Actions
 
  
Speak text: You received a new value [lv=VARNAME1]
+
''Remote control for smart home lights via webhook URL call.''
</pre><br>
 
<pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
 
Constrains
 
  
 +
----
  
</pre><br>
+
  <pre class="trigger-style">Triggers
<pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
 
Local variables
 
  
VARNAME1 [Hello] (Type String)
+
Webhook (URL): set_volume</pre>
</pre><br>
+
  <pre class="action-style">Actions
 +
 
 +
Set Volume - Media: [volume_level]
 +
Speak Text: Volume set to [volume_level]</pre>
 +
 
 +
''Set device volume remotely by calling: https://trigger.macrodroid.com/[device-id]/set_volume?volume_level=50''
 +
 
 +
''' Notes '''
 +
 
 +
* Requires Google Play Services and Firebase Cloud Messaging to function. Will not work on devices without Google Services.
 +
* The URL is unique to each device and will change if the app is reinstalled or all app data is cleared.
 +
* Use the Export/Import Device ID feature to preserve webhook URLs when switching devices.
 +
* IP Address Whitelist supports wildcards (* and ?) and Magic Text for dynamic IP matching.
 +
* Variable Whitelist protects against unauthorized variable modifications when enabled.
 +
* POST request body content is limited to 3800 characters when saving to a variable.
 +
* The webhook is delivered via cloud push notification, so the device needs internet connectivity.
 +
 
 +
''' See Also '''
 +
 
 +
* [[Action:_HTTP_Request|HTTP Request Action]]
 +
* [[Trigger:_HTTP_Server_Request|HTTP Server Trigger]]
 +
* [[Trigger:_Intent_Received|Intent Received Trigger]]

Latest revision as of 22:10, 7 January 2026

This trigger will fire on this device when the specified web URL is called from anywhere. The webhook uses Firebase Cloud Messaging to deliver notifications to your device, enabling remote triggering of macros from any device or service that can make HTTP requests.

Options

  • Identifier: Custom text appended to your webhook URL (e.g., "mywebhook" creates https://trigger.macrodroid.com/[device-id]/mywebhook)
  • IP Address Whitelist: Restrict which IP addresses can trigger the webhook (supports wildcards and Magic Text)
  • Variable Whitelist: Enable to restrict which variables can be updated via webhook parameters
  • Save Body to Variable: Save the HTTP POST request body to a string variable (max 3800 characters)

URL Format

Your webhook URL follows this format:

https://trigger.macrodroid.com/[device-id]/[identifier]

Passing Variables

Variables can be passed via URL query parameters:

  • Single variable: ?VARNAME=value
  • Multiple variables: ?VARNAME1=42&VARNAME2=text
  • Dictionary/Array values: ?mydict(KEY)=VALUE or ?mydict(KEY1)(KEY2)=VALUE

Supported variable types: String, Integer, Decimal, Boolean

Device ID Management

  • Export Device ID: Share your device ID with password protection to port to a new device
  • Import Device ID: Import a previously exported device ID to maintain existing webhook URLs
  • Generate New Device ID: Create a new device ID (invalidates all existing webhook URLs)
  • Refresh Cloud Token: Re-upload the Firebase Cloud Messaging token to resolve connection issues

TinyURL Integration

Generate a shortened URL via TinyURL for easier sharing. The shortened URL format is:

[tinyurl]/[identifier]

Local Variables

Magic text variables available with this trigger include:

  • Webhook request IP address
  • Query parameters

Examples

Triggers

Webhook (URL): lights_on
Actions

Send Intent: Turn on smart lights
Notification: Lights turned on via webhook

Remote control for smart home lights via webhook URL call.


Triggers

Webhook (URL): set_volume
Actions

Set Volume - Media: [volume_level]
Speak Text: Volume set to [volume_level]

Set device volume remotely by calling: https://trigger.macrodroid.com/[device-id]/set_volume?volume_level=50

Notes

  • Requires Google Play Services and Firebase Cloud Messaging to function. Will not work on devices without Google Services.
  • The URL is unique to each device and will change if the app is reinstalled or all app data is cleared.
  • Use the Export/Import Device ID feature to preserve webhook URLs when switching devices.
  • IP Address Whitelist supports wildcards (* and ?) and Magic Text for dynamic IP matching.
  • Variable Whitelist protects against unauthorized variable modifications when enabled.
  • POST request body content is limited to 3800 characters when saving to a variable.
  • The webhook is delivered via cloud push notification, so the device needs internet connectivity.

See Also