# Right click context menu inject timestamp msg

**URL:** <https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068>\
**Category:** Feature Requests\
**Created:** [27 December 2023 19:19 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068 "2023-12-27T19:19:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [27 December 2023 19:19 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/1 "2023-12-27T19:19:40Z")

</div>

I often need to prod a node as part of testing or a one off trigger.  
Mostly to do this I'm adding an inject node, wiring it up, deploy then press the inject node to fire it, then remove it and deploy again. For sure this is most definitely a first world problem....

I think it would be great to have a right click context option to fire a timestamp inject to any input node connector...!

Simply hover the mouse over left side connector of any node, right click and select 'Inject'.  
Perhaps the default is a timestamp, but maybe make this configurable?

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [27 December 2023 19:41 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/2 "2023-12-27T19:41:42Z")

</div>

I see it more as a utility rather than a built-in feature - I believe it's doable with a plugin.

The idea would be to configure the default message in the sidebar and trigger the action by clicking on the link and... I don't really know.

I would add an option: yours allows to send a message and I would like to add a kind of box that hangs on the wire and listens for messages (the message can be displayed in the sidebar).

This principle exists when monitoring PLCs - the mouse looks like a kind of arrow that we are going to click on a wire to see status. Maybe @Steve-Mcl sees what I mean

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [27 December 2023 21:24 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/3 "2023-12-27T21:24:20Z")

</div>

Do plug-ins allow for the creation of context sensitive menu options? Perhaps the function could be an integration, maybe, but the action to fire it needs to be seamless, hence the suggestion of it being in the right click context menu....

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [27 December 2023 22:30 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/4 "2023-12-27T22:30:55Z")

</div>

There is a node:

> **[node-red-contrib-resend-last-msg](https://flows.nodered.org/node/node-red-contrib-resend-last-msg)**
>
> Resend last message received

May work for you.

Put it at _critical_ points in your flows.  
Then if/when you need to test, it is there.

---

<div class="post-metadata">

**Author:** ![dougle03](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dougle03/32/32979_2.png) [@dougle03](https://discourse.nodered.org/u/dougle03)\
**Post date:** [27 December 2023 23:01 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/5 "2023-12-27T23:01:33Z")

</div>

Thanks, but I'm after a facility that does not require additional nodes being added.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [27 December 2023 23:03 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/6 "2023-12-27T23:03:49Z")

</div>

It already exists 🤯, all that remains is to add a section allowing to trigger a message.

@knolleary, next feature: inject message 🤩

> **[GitHub - node-red/node-red-debugger: A flow debugger for Node-RED 2.x](https://github.com/node-red/node-red-debugger)**
>
> A flow debugger for Node-RED 2.x. Contribute to node-red/node-red-debugger development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [28 December 2023 01:33 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/7 "2023-12-28T01:33:22Z")

</div>

You can set / change the test msg and hit **inject now**  
without the need to Deploy each time

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f00182f0906e3eaf1de10fd0e035ea59f8dcec35.png)

ps. You still need an Inject node though

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [28 December 2023 07:52 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/8 "2023-12-28T07:52:30Z")

</div>

> [@dougle03](#):
>
> Do plug-ins allow for the creation of context sensitive menu options?

Hi @dougle03,

I am not an expert on this, but going to give some information because I find your question both interesting and useful.

I "think" this are in fact two separate feature requests, but I might be fully mistaken:

1. Ability to show custom menu items in the contextmenu via a plugin. Because I don't see any plugin related in the contextmenu [code](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/editor-client/src/js/ui/contextMenu.js#L191). You can only hide or show the contexmenu.

2. Ability to inject a message to a wire instead of into a node. I "think" this is currently not possible. Because when I look at the [code](https://github.com/node-red/node-red/blob/master/packages/node_modules/%40node-red/nodes/core/common/20-inject.html#L203) of the Inject node's _"Inject now"_ button, it calls the server-side to inject the message into the (Inject) node and not into a wire.

Like always you could start hacking to show a custom menu in the contextmenu, but I think that would be a _ **bad idea** _ because it looks dirty & has performance impact & might break with a feature version of Node-RED! You could do that by observe the document body in the plugin and add your custom menu item as soon as the contextmenu is being displayed:

```auto
    let callback = function(mutationsList, observer) {
        for(let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                for(let node of mutation.addedNodes) {
                    // When the contextmenu is created (i.e. added to the html body of the flow editor)
                    if(node.id === 'red-ui-workspace-context-menu'){
                        const selection = RED.view.selection()
                        const wireLinks = (selection.links && selection.links.filter(e => !e.link)) || [];

                        // Only add the custom menu item when 1 wire has been selected
                        if (wireLinks.length === 1) {
                            let menuLabel = 'Inject message';

                            // Append a custom menu item "Inject message" to the contextmenu
                            let html = '<li><a id="red-ui-menu-item-57" tabindex="-1" href="#"><span class="red-ui-menu-label"><span>' + menuLabel + '</span></span></a></li>';
                            $liElement = $(node).append(html);

                            $liElement.on('click', 'li', function() {
                                // Put your code here to do something
                                alert('Your custom menu item has been clicked');
                            });
                        }
                    }
                }
            }
        }
    };

    // Start observing the immediate child elements of the document body
    var observer = new MutationObserver(callback);
    observer.observe(document.body, { childList: true });

```

Which will only show your custom menu item if 1 wire has been selected:

![custom menu item](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/1/b1c31b32ee3ce98315b9b89817291ceb75358be6.gif)

But again: I created quickly this code snippet only out of technical interest. But it will not be performant to observe the DOM, so I would _ **NOT** _ do it this way!

Hopefully your feature requests will be accepted, so developers can add stuff like this in a clean way.

BTW For people that don't like custom context menu items: simply don't install the plugin 😉

Bart

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 December 2023 08:40 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/9 "2023-12-28T08:40:28Z")

</div>

Wires can’t have properties, and you can’t inject to a wire. Luckily the original request is to inject into the input port of a node.

Hard part I see is how to make the input easily customisable as most nodes need more than a simple timestamp injected. And even if you do that, do you have to set it per node ? Or just once globally, and then have to change it for each place you want to inject. Becomes more a simple right click each time imho.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [28 December 2023 08:59 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/10 "2023-12-28T08:59:12Z")

</div>

> [@dceejay](#):
>
> Luckily the original request is to inject into the input port of a node

Ah ok, I had overlooked that. Thanks for the clarification!

> [@dceejay](#):
>
> most nodes need more than a simple timestamp injected

It looks - to me at least- that you need to show the screen of an inject node, with some of the buttons invisible (i e. only the _" Inject now"_ button)...

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 December 2023 09:32 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/11 "2023-12-28T09:32:41Z")

</div>

> [@UnborN](#):
>
> You can set / change the test msg and hit **inject now**

thanks for the that, hadn't noticed it before but extremely useful.

I was going to say that "inject now" combined with the quick connect feature of 3.1.x and the OP has their solution but ....

![injectnow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cbaf2d0c16d7fd2abad8f0663d7c5582f209ec73.gif)

there is a deploy inbetween ☹

rename it to "deploy & inject now" and we have it! 😉

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 December 2023 09:57 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/12 "2023-12-28T09:57:20Z")

</div>

> [@gregorius](#):
>
> rename it to "deploy & inject now" and we have it!

The whole point was NOT to deploy so thanks but no thanks ! 🙏

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 December 2023 10:00 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/13 "2023-12-28T10:00:02Z")

</div>

> [@dceejay](#):
>
> The whole point was NOT to deploy so thanks but no thanks

So the idea is to simulate flow execution BEFORE doing a deploy?

In that case, take the in-browser static version of Node-RED --\> [https://cdn.flowhub.org](https://cdn.flowhub.org) --\> import flow there and nothing can happen.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 December 2023 10:01 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/14 "2023-12-28T10:01:25Z")

</div>

You can simply deploy before opening and editing the inject rules.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 December 2023 10:03 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/15 "2023-12-28T10:03:30Z")

</div>

Sure but I think it's about being faster than Lucky Luke - i.e. the deploy (Ctrl-D) is one step too much.

Either way, I was just trying to find a sensible workable compromise for the original question...

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 December 2023 10:07 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/16 "2023-12-28T10:07:49Z")

</div>

> [@gregorius](#):
>
> Sure but I think it's about being faster than Lucky Luke - i.e. the deploy (Ctrl-D) is one step too much.

Drag wire, press ctrl , press return, press ctrl d. Not really that much slower. The dragging the wire is most probably the bottle neck operation.

[edit] If there was a shortcut action press selected node button, it would be a very quick operation to inject a timestamp msg.

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [28 December 2023 10:46 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/17 "2023-12-28T10:46:30Z")

</div>

This is why I proposed the idea of the plugin - the request being linked to development, the injection option should not be found directly in the NR core but added (to the core) from a plugin.

The message parameters must be easily modifiable - only the sidebar allows this.

As mentioned above, there is already a (debugger) plugin allowing to see messages in a desired position (this is more my addition of the request than the one wanted here), all that is missing is message injection.

It's entirely possible to do and it will be just as simple to use - just need to add a plugin.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 December 2023 12:05 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/18 "2023-12-28T12:05:04Z")

</div>

I think that the idea of being able to inject to a non-deployed flow is very uncertain. Do we have any idea of the impact on existing nodes? Why would we have any expectation that nodes would behave correctly if not deployed?

On the other hand, having a more dynamic inject mechanism to be able to inject a message into a deployed flow without an extra deploy - that seems sensible and should be doable surely? Since all that is needed is a way to form a msg object and inject. The first part is fairly simple web form and JS - and possibly mostly already exists in the HTML for the Inject node (and as I've discovered recently, it isn't hard to separate out the parts of the node's Editor HTML into separate files and make them reusable). The 2nd part, I suspect, already exists in the core code.

---

<div class="post-metadata">

**Author:** ![gregorius](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gregorius/32/73816_2.png) [@gregorius](https://discourse.nodered.org/u/gregorius)\
**Post date:** [28 December 2023 12:45 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/19 "2023-12-28T12:45:13Z")

</div>

> [@TotallyInformation](#):
>
> that seems sensible and should be doable surely?

That's the inject now button on the inject node that you describe - if the inject node _is_ deployed, then inject node will dynamically - without further deployment - insert new messages into the flow.

> [@GogoVega](#):
>
> It's entirely possible to do and it will be just as simple to use - just need to add a plugin.

Having played around with the static version of Node-RED, I can tell you that's it's completely doable. You can navigate throughout the entire flow in the frontend - how? see this [code](https://github.com/gorenje/cdn.flowhub.org/blob/main/red/deadred.js) - that basically simulates a flow execution purely in the frontend.

The issues arise when code in the frontend _hasn't_ been deployed but is run in the frontend, then you mileage starts varying.

For me, this is starting to sound like "simulation mode" within Node-RED: I simulate the execution of the flow _purely_ in the frontend. I would also not put this into the core of Node-RED since it's extremely confusing for any type of user. Plus: Node-RED is not a dashboard! 😉

---

<div class="post-metadata">

**Author:** ![GogoVega](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gogovega/32/71313_2.png) [@GogoVega](https://discourse.nodered.org/u/GogoVega)\
**Post date:** [28 December 2023 12:52 UTC](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068/20 "2023-12-28T12:52:22Z")

</div>

> [@TotallyInformation](#):
>
> I think that the idea of being able to inject to a non-deployed flow is very uncertain

It is to be able to inject without having to deploy the inject node, it is not possible to trigger another non-deployed node.

> [@TotallyInformation](#):
>
> that seems sensible and should be doable surely?

The plugin exists, just need to add an HTML part (like a button/shortcut or something else on the node input) which sends a request to the runtime and it is the latter which triggers the flow - no need for more code, it's quite simple to do. Just see with Nick how to set it up

> [@gregorius](#):
>
> I would also not put this into the core of Node-RED since it's extremely confusing for any type of user.

Exactly, it's a debugging tool so let's put it in its place

[Next page](https://discourse.nodered.org/t/right-click-context-menu-inject-timestamp-msg/84068.md?page=2)
