Changes

no edit summary
Line 1: Line 1: −
== About ==
+
<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>
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
This trigger will fire on this device when the specified web URL is called from anywhere.
  −
</pre>
  −
More information here.
  −
https://medium.com/@macrodroid/introducing-the-webhook-trigger-a760e2ee140d
     −
===<p><b>Warning</b></p>===
+
''' Options '''
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
that the URL is unique to this device and the URL will change if the application is reinstalled (or all application data is deleted).
     −
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.)
+
* '''Identifier''': Custom text appended to your webhook URL (e.g., "mywebhook" creates https://trigger.macrodroid.com/[device-id]/mywebhook)
</pre>
+
* '''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)
   −
==<p><b>Request configuration</b></p>==
+
''' URL Format '''
   −
=== Identifier ===
+
Your webhook URL follows this format:
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
<pre>https://trigger.macrodroid.com/[device-id]/[identifier]</pre>
The identifier is what is after the base url.
  −
Base URL:
     −
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-677d4d/
+
''' Passing Variables '''
   −
E.G. The identifier would be 'mywebhook'
+
Variables can be passed via URL query parameters:
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-677d4d/mywebhook
  −
</pre>
     −
=== IP address whitelist ===
+
* '''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>
   −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
Supported variable types: String, Integer, Decimal, Boolean
You can support one or more IP addresses so that the webhook is only activated from specific IP addresses.
  −
It also supports magic text '...'
  −
</pre>
  −
* ''[[magic text|Magic text list]] ''
  −
</pre>
  −
=== Save body to string variable ===
  −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
If your HTTP POST request contains any text format, you can save it in any string variable.
     −
Note that due to limits imposed by Firebase Cloud Messaging the maximum body text length is 3800 characters.
+
''' Device ID Management '''
</pre>
  −
* ''[[Variables]]''
  −
</pre>
     −
==<p><b>URL short</b></p>==
+
* '''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 ===
+
''' TinyURL Integration '''
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
It is a URL shortening service used to create shorter, more shareable links.
  −
You can use it to shorten your urls, go from this:
  −
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-677d4d/mywebhook
  −
to this:
  −
http://tinyurl.com/5xzj7w6j
  −
</pre>
     −
==<p><b>Include variables</b></p>==
+
Generate a shortened URL via TinyURL for easier sharing. The shortened URL format is:
 +
<pre>[tinyurl]/[identifier]</pre>
   −
=== String, Integer, Decimal, Boolean ===
+
''' Local Variables '''
   −
* '' [https://macrodroidforum.com/wiki/index.php/Variables#Standard_Variable_Types Variables | String, Integer, Decimal, Boolean] ''
+
Magic text variables available with this trigger include:
 +
* Webhook request IP address
 +
* Query parameters
   −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
''' Examples '''
ID = User-defined identifier.
     −
VAR1 = The first variable to be defined, in this case with a numerical value.
+
  <pre class="trigger-style">Triggers
   −
VAR2 = The second variable to be defined, in this case with a plain-text value.
+
Webhook (URL): lights_on</pre>
 +
  <pre class="action-style">Actions
   −
To set a variable:
+
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>
   −
To set multiple variables:
+
''Remote control for smart home lights via webhook URL call.''
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=42&VARNAME2=Hello_World
  −
</pre>
  −
* '' An introduction video is available'' ''[https://youtu.be/0V_EcyhxrpA?si=_mjXwGVXHO3J8Ywp MacroDroid Variables]''
     −
=== Dictionary - Array ===
+
----
   −
* ''[https://macrodroidforum.com/wiki/index.php/Variables#Data_Structure_Variable_Types Variables | Dictionary - Array] ''
+
  <pre class="trigger-style">Triggers
   −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
Webhook (URL): set_volume</pre>
id = User-defined identifier.
+
  <pre class="action-style">Actions
   −
mydict = It is a dictionary type variable for the example.
+
Set Volume - Media: [volume_level]
 +
Speak Text: Volume set to [volume_level]</pre>
   −
KEY = It is the key or entry of the dictionary.
+
''Set device volume remotely by calling: https://trigger.macrodroid.com/[device-id]/set_volume?volume_level=50''
   −
VALUETEXT = It is the value you want to send.
+
''' Notes '''
   −
For Dictionaries / Array:
+
* Requires Google Play Services and Firebase Cloud Messaging to function. Will not work on devices without Google Services.
https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/id?mydict(KEY)=VALUETEXT
+
* The URL is unique to each device and will change if the app is reinstalled or all app data is cleared.
</pre>
+
* Use the Export/Import Device ID feature to preserve webhook URLs when switching devices.
* '' An introduction video is available Using'' ''[https://youtu.be/u2zY5dv34CM Dictionary and Array Variables]''
+
* IP Address Whitelist supports wildcards (* and ?) and Magic Text for dynamic IP matching.
<br>
+
* 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.
   −
==<p><b>Webhook management</b></p>==
+
''' See Also '''
   −
=== Export device ID to new device ===
+
* [[Action:_HTTP_Request|HTTP Request Action]]
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
+
* [[Trigger:_HTTP_Server_Request|HTTP Server Trigger]]
You will be asked to create a password (it will be linked to your current device ID) and you can import it later in case your device is damaged or you update your current device.
+
* [[Trigger:_Intent_Received|Intent Received Trigger]]
 
  −
Later you can use the 'Import device ID from another device' option to restore your previous Device ID.
  −
</pre><br>
  −
 
  −
=== Import device ID from other device ===
  −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
You will be asked for the Device ID and password and you will be able to correctly import the Device ID.
  −
</pre><br>
  −
 
  −
=== Generate new device ID ===
  −
 
  −
<pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
  −
This will assign a new device id to this device. Existing webhook links for this device will no longer function.
  −
To get a new device ID you just need to check the 'I have read and understood' box
  −
and you can generate your new device ID.
  −
</pre>