| 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
| |
| − | <br>
| |
| | | | |
| − | ===<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><br>
| + | * '''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>Parameters</b></p>===
| + | ''' URL Format ''' |
| − | * ''''' IP address whitelist '''''
| |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| |
| − | 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><br>
| |
| | | | |
| − | * ''''' Save body to string variable '''''
| + | 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> |
| − | 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.
| + | ''' Passing Variables ''' |
| − | </pre>
| |
| − | '''''[[Variables]]''''' | |
| − | </pre><br>
| |
| | | | |
| − | * ''''' TinyUrl '''''
| + | Variables can be passed via URL query parameters: |
| − | <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><br>
| |
| | | | |
| − | ===<p><b>Formats to include variables</b></p>===
| + | * '''Single variable''': <code>?VARNAME=value</code> |
| − | * ''''' Identifier''''' | + | * '''Multiple variables''': <code>?VARNAME1=42&VARNAME2=text</code> |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | + | * '''Dictionary/Array values''': <code>?mydict(KEY)=VALUE</code> or <code>?mydict(KEY1)(KEY2)=VALUE</code> |
| − | The identifier is what is after the base url.
| |
| − | Base URL:
| |
| | | | |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-677d4d/
| + | Supported variable types: String, Integer, Decimal, Boolean |
| | | | |
| − | E.G. The identifier would be 'mywebhook'
| + | ''' Device ID Management ''' |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-677d4d/mywebhook
| |
| − | </pre><br>
| |
| − | * ''''' Attach variable value [[Variables|String, Integer, Decimal, Boolean]] '''''
| |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| |
| − | ID = User-defined identifier.
| |
| | | | |
| − | VAR1 = The first variable to be defined, in this case with a numerical value.
| + | * '''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 |
| | | | |
| − | VAR2 = The second variable to be defined, in this case with a plain-text value.
| + | ''' TinyURL Integration ''' |
| | | | |
| − | To set a variable:
| + | Generate a shortened URL via TinyURL for easier sharing. The shortened URL format is: |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=Hello
| + | <pre>[tinyurl]/[identifier]</pre> |
| | | | |
| − | To set multiple variables:
| + | ''' Local Variables ''' |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/ID?VARNAME1=42&VARNAME2=Hello_World
| |
| − | </pre>
| |
| − | ''''' An introduction video is available MacroDroid Variables https://youtu.be/0V_EcyhxrpA?si=_mjXwGVXHO3J8Ywp ''''' | |
| − | <br>
| |
| | | | |
| − | <br>
| + | Magic text variables available with this trigger include: |
| − | * ''''' Attach Data Structure [[Variables|Dictionary - Array]] ''''' | + | * Webhook request IP address |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | * Query parameters |
| − | id = User-defined identifier.
| |
| | | | |
| − | mydict = It is a dictionary type variable for the example.
| + | ''' Examples ''' |
| | | | |
| − | KEY = It is the key or entry of the dictionary.
| + | <pre class="trigger-style">Triggers |
| | | | |
| − | VALUETEXT = It is the value you want to send.
| + | Webhook (URL): lights_on</pre> |
| | + | <pre class="action-style">Actions |
| | | | |
| − | For Dictionaries / Array:
| + | Send Intent: Turn on smart lights |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/id?mydict(KEY)=VALUETEXT
| + | Notification: Lights turned on via webhook</pre> |
| − | </pre>
| |
| − | ''''' An introduction video is available Using Dictionary and Array Variables https://youtu.be/u2zY5dv34CM '''''
| |
| − | <br></pre>
| |
| | | | |
| − | ===<p><b>Webhook management</b></p>===
| + | ''Remote control for smart home lights via webhook URL call.'' |
| − | * ''''' Export device ID to new device '''''
| |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| |
| − | 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.
| |
| | | | |
| − | 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 class="trigger-style">Triggers |
| − | <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 '''''
| + | Webhook (URL): set_volume</pre> |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;"> | + | <pre class="action-style">Actions |
| − | 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><br>
| |
| | | | |
| − | ===<p><b>Examples</b></p>===
| + | Set Volume - Media: [volume_level] |
| | + | Speak Text: Volume set to [volume_level]</pre> |
| | | | |
| − | <pre style="background-color: #ACC8E5; color: #112A46; border-radius: 10px; padding: 10px;">
| + | ''Set device volume remotely by calling: https://trigger.macrodroid.com/[device-id]/set_volume?volume_level=50'' |
| − | This macro will receive values by webhook and speak them by TTS.
| |
| − | </pre><br>
| |
| − | <pre style="background-color: #AC2424; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Triggers
| |
| | | | |
| − | Webhook (MyWebhook)
| + | ''' Notes ''' |
| − | https://trigger.macrodroid.com/c306bcd7-5f78-4895-bee4-69600af77d4d/id?VAR1=Hello
| |
| − | </pre><br>
| |
| − | <pre style="background-color: #1665B0; color: white; border-radius: 10px; padding: 10px;">
| |
| − | Actions
| |
| | | | |
| − | Speak text: You received a new value {lv=VAR1}
| + | * Requires Google Play Services and Firebase Cloud Messaging to function. Will not work on devices without Google Services. |
| − | </pre><br>
| + | * The URL is unique to each device and will change if the app is reinstalled or all app data is cleared. |
| − | <pre style="background-color: green; color: white; border-radius: 10px; padding: 10px;">
| + | * Use the Export/Import Device ID feature to preserve webhook URLs when switching devices. |
| − | Constraints
| + | * 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 ''' |
| | | | |
| − | </pre><br>
| + | * [[Action:_HTTP_Request|HTTP Request Action]] |
| − | <pre style="background-color: teal; color: white; border-radius: 10px; padding: 10px;">
| + | * [[Trigger:_HTTP_Server_Request|HTTP Server Trigger]] |
| − | Local variables
| + | * [[Trigger:_Intent_Received|Intent Received Trigger]] |
| − | | |
| − | VAR1 = Hello (Type String)
| |
| − | </pre><br>
| |