Trigger a flow from external call (QUESTION)

Hello everyone, i'm new on node-red and trying to integrate this with a Hyperledger Client (that is baiscally Angular 4) and i need to send an email when the user send a transaction on hyperledger.

In the docs of Hyperledger (https://hyperledger.github.io/composer/v0.16/integrating/call-out - on example bellow), they say that is possible to "call Node-RED running on Bluemix", well, i run my own instance of local node-red, build a flow that start with a injection but i can't figure out:

How to trigger that like they do in docs?

I can't figure out too if is possible and how trigger this flow from Angular client (with something like a GET/POST request from client to node-red.)

Here my flow:
Screenshot%20from%202019-03-18%2011-03-15
(The flow actually works if clicked)

Thank you all! and sorry if is a bad question.

Hi @defremont

You can use the HTTP nodes to create a flow that can be triggered by http requests. The cookbook has a number of useful examples: https://cookbook.nodered.org/http/

The problem you may face is whether whatever is making the HTTP request is able to 'see' your instance of Node-RED. If you are running it locally, you presumably mean on your local network. That means it is not visible to the wider internet.

1 Like

Thank you @knolleary, reading these docs right now..

About the problem, the HTTP request will be triggered by a function in the smart contract running locally too, so i think this will works even the users trigger from published client of this server.

By the way, is just a proof of work, not production version.

Thanks again!

Ok, now when i click the test button, nothing happens.

the node-red config

test button function:

test(){
this.http.get('http://127.0.0.1:1880/hello');

}

In a situation like this it is very helpful if you provide your flow, espically as you say this is just a test.

Also provide
os platform and release
versions of NR and node.js

Also where is this button you are pressing?

P.S. having just installed the Create an HTTP Endpoint flow on my local machine, when I click the link in your post, the Hello World is returned

1 Like

Using Ubuntu 16.04 LTS
node 8.15
npm 6.4,
Node-RED 0.20.2
I'm triggering from a Angular 4 app
The flow:
[{"id":"35dcdbd9.a99684","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"dcdb9a4e.db2eb8","type":"debug","z":"35dcdbd9.a99684","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":450,"y":180,"wires":[]},{"id":"aa98d38f.846af","type":"e-mail","z":"35dcdbd9.a99684","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"andre.def93@gmail.com","dname":"","x":500,"y":320,"wires":[]},{"id":"f1aea493.ec0e78","type":"http response","z":"35dcdbd9.a99684","name":"","statusCode":"","headers":{},"x":670,"y":260,"wires":[]},{"id":"747c3f58.892dd","type":"http in","z":"35dcdbd9.a99684","name":"","url":"/hello","method":"get","upload":false,"swaggerDoc":"","x":120,"y":260,"wires":[["dcdb9a4e.db2eb8","aa98d38f.846af","f1aea493.ec0e78"]]}]

My component.ts:

[...]

import { Http } from '@angular/http';
[...]
constructor(
        private http: Http,
[...]
    ) { }
[...]
test(){
       this.http.get('http://127.0.0.1:1880/hello');
    }

My component.html:

[...]

                <button class="primary" (click)="test()">
            <div *ngIf="!issueInProgress">
                <span>TEST</span>
            </div>
        </button>
[...]

Well I can't help you with the Angular app, but the flow is working fine. So your reall question should be "In an Angular 4 App, how do I link to an internal/external site." Once you can get thaat going, getting to NR will be easy. But I think you will need to ask that on a n Angular form....

1 Like

Thanks for you time. Is great to know that my NR code is fine. all the tips helped me.
Now i will find some solutions about Angular.