# How to connect android phone via websocket with Node-RED to recieve messages

**URL:** https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127
**Category:** General
**Created:** [16 September 2021 23:13 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127 "2021-09-16T23:13:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![peterminztee](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@peterminztee](https://discourse.nodered.org/u/peterminztee)
#### Post date: [16 September 2021 23:13 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/1 "2021-09-16T23:13:29Z")

</div>

Hi I am currently working on a project for my university and I am not really familiar with Node-RED, and Java Websockets.

Bascily the Project is a voice assistant:

1. you speak into a Rasspberry PI which runs Rhasspy(voice to text) -\> creating intents -\> which are send to Node-RED in Json format
2. Node-RED recieves intents in Json Format. -\> send to Android App(jsut display data for now)
3. I want to get the data on my android Phone.

Right now I have my Rasspberry PI connected with my Node-RED server and I am sending "intents" which contain data in Json format this is working so far. For example I say: " how is the weather " -\> I get via an input websocket: Intent: object  
name: "weather"  
.....  
text: "how is the weather"

Now I want to get this data in Json format with my android(running Java and want to use Websockets(OkHttp) ) phone via websockets but I am not sure how to get it are there already any example on how to connect my phone to the Node-RED server and get the Json data?

My idea now:

1. Run a websocket client on my phone which connects to Node-RED:ws://......:1880
2. Create "output websocket" in Node-RED which sends payload(Json data) to my android  
--\> now jsut display text^^

Excuse my english is not my mother language 😃  
I appreciate any help and idea 🙂🖖

---

<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: [16 September 2021 23:17 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/2 "2021-09-16T23:17:20Z")

</div>

you could install node-red on the phone using termux app. On my other devices i have automate with a mqtt tasker plugin.

---

<div class="post-metadata">

### Author: ![peterminztee](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@peterminztee](https://discourse.nodered.org/u/peterminztee)
#### Post date: [16 September 2021 23:48 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/3 "2021-09-16T23:48:12Z")

</div>

Thank you already 🙂  
is there any good guide/example?  
🖖

---

<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: [17 September 2021 01:05 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/4 "2021-09-17T01:05:32Z")

</div>

Yes in the getting started section of the documentation link above  
[https://nodered.org/docs/getting-started/android](https://nodered.org/docs/getting-started/android)

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [17 September 2021 13:33 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/5 "2021-09-17T13:33:00Z")

</div>

What are you going to do with the data once you have it in the phone. Have you considered something like Telegram if you are just trying to get notifications?

---

<div class="post-metadata">

### Author: ![peterminztee](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@peterminztee](https://discourse.nodered.org/u/peterminztee)
#### Post date: [20 September 2021 11:49 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/6 "2021-09-20T11:49:53Z")

</div>

Hi, once I get the data on my phone I want to build an URL with the recieved data for REST-API.

For example you ask "what food today in mensa" -\> I build URL for example: https......./mensa/today -\> and phone will be able to displlay JSON from Rest-API

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [20 September 2021 12:45 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/7 "2021-09-20T12:45:43Z")

</div>

> [@peterminztee](#):
>
> once I get the data on my phone I want to build an URL

Are you going to write an Android app for that?

---

<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: [20 September 2021 12:57 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/8 "2021-09-20T12:57:24Z")

</div>

Automate would do all that, no need to install node-red As said you can run a mqtt or http plugin or use google firebase messaging, and receive the data, Automate can display notification, dialogs or you can use Web dialogs and build your own html/javascript page. This would probably be less resource/battery hungry. Automate could also call your rest API

---

<div class="post-metadata">

### Author: ![peterminztee](https://avatars.discourse-cdn.com/v4/letter/p/ba9def/32.png) [@peterminztee](https://discourse.nodered.org/u/peterminztee)
#### Post date: [20 September 2021 21:20 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/9 "2021-09-20T21:20:55Z")

</div>

yes, I wrote already an APP hardcoded for Rest-API so far but want to switch it to the correct url with the recieved parameter from Node RED and Tasker so my app is more flexible and I get correct data on display 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [19 November 2021 21:21 UTC](https://discourse.nodered.org/t/how-to-connect-android-phone-via-websocket-with-node-red-to-recieve-messages/51127/10 "2021-11-19T21:21:07Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
