# How to send a push confirmation from homeyscript

**URL:** <https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704>\
**Category:** Developers\
**Tags:** homeyscript, flow, homey-pro\
**Created:** [September 11, 2022, 1:16am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704 "2022-09-11T01:16:49Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 11, 2022, 1:16am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/1 "2022-09-11T01:16:49Z")

</div>

Hi all,

I’m trying to get a push confirmation working from HomeyScript.  
The script does not return an error… I use it in Adv.Flow card “And - homeyscript run script”  
Sending a push message works fine, but the confirm version does not work yet.  
Any thoughts?

```auto
// send push confirmation to user
Homey.flow.runFlowCardAction({
        uri: 'homey:manager:mobile',
        id: 'push_confirm',
        args: {
			    user: {
			    athomId: 'myAthomIDhere'
		    	},
		    text: 'Test push confirmation test-push_confirmation.js'
        },
      });
  return(true);

```

.  
This script works OK:

```auto

// send push msg to user
Homey.flow.runFlowCardAction({
        uri: 'homey:manager:mobile',
        id: 'push_text',
        args: {
			    user: {
			    athomId: 'myAthomIDhere'
		    	},
		    text: 'Test push notification test_pushmessage.js'
        },
      });

```

(Note: The AthomID of users can be found by running  
`Homey.users.getUsers();`  
in [web-api playground](https://tools.developer.homey.app/tools/api-playground))

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [September 11, 2022, 7:46am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/2 "2022-09-11T07:46:35Z")

</div>

The push confirmation isn’t an action card (THEN column) but a condition card (AND column), not sure that is possible.

---

<div class="post-metadata">

**Author:** ![Jero](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jero/32/17556_2.png) [@Jero](https://community.homey.app/u/Jero)\
**Post date:** [September 11, 2022, 10:59am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/3 "2022-09-11T10:59:28Z")

</div>

You need to add await before `Homey.flow.runFlowCardAction`. The script is erroring after it is done executing so your wont be able to see the error.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/9/f9f663439c9778054ec9c6fd0accefcb77c9529f.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [September 11, 2022, 6:17pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/4 "2022-09-11T18:17:24Z")

</div>

Thanks Jeroen, tried earlier and got the error as well.  
But, nów I suddenly get the “action” part, thanx Caseda.  
While that card is a condition card, the “run flowcard” has to be the condition type as well 🤪

Very nice, this works now:

```auto
const response = await Homey.flow.runFlowCardCondition({
        uri: 'homey:manager:mobile',
        id: 'push_confirm',
        args: {
			    user: {
			    athomId: MyUserAthomID
		    	},
		    text: 'Test push confirmation from HomeyScript, now choose Yes to confirm; for No, just ignore this:'
        },
      });
  log (response);    
  return(true);

```

.  
A follow up question:  
Replying the pushmessage with either yes or no, results in yes and the flow continues. Is that as designed?  
Because, when the message is sent, and I _don’t_ respond to the question, the flow stops.  
So now we have a “Should I do action A, press Yes; if not, don’t respond” option.  
I was expecting a  
-Yes: do this  
-No: do nothing, or do something else

---

<div class="post-metadata">

**Author:** ![Marijn\_Hilbrink](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marijn_hilbrink/32/55855_2.png) [@Marijn\_Hilbrink](https://community.homey.app/u/Marijn_Hilbrink)\
**Post date:** [November 11, 2022, 2:10pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/5 "2022-11-11T14:10:56Z")

</div>

This post helps me, but can you send also a image from the gallery? The card exist in the flowmanager but need this in a homey script.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 11, 2022, 3:09pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/6 "2022-11-11T15:09:06Z")

</div>

Run the example flowcard list, and in the returned data, search for the app id of the app you use. It will show all app’s flowcards you can use in HS.

 ![Screenshot_20221111-160232_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/a/fa6ee051d45bbfd86bff145ef6dec6367640120f.jpeg)

You can find the app id in the app’s appstore URL. It is the reversed ‘url’ right after /app/  
For instance, this is the app id for the Homeyscript app

 ![Screenshot_20221111-160639_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/9/e9f9dcc454b7d23c74965ddbc031d1665b2455ef.jpeg)

You can also find it here, [https://tools.developer.homey.app/tools/devices](https://tools.developer.homey.app/tools/devices) when you search for a device of your app in question

 ![Screenshot_20221111-161239_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/c/1cd7a0314ac119a3cfb9b6ffca0312ad7119519b.jpeg)

---

<div class="post-metadata">

**Author:** ![Marijn\_Hilbrink](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marijn_hilbrink/32/55855_2.png) [@Marijn\_Hilbrink](https://community.homey.app/u/Marijn_Hilbrink)\
**Post date:** [November 12, 2022, 3:56pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/7 "2022-11-12T15:56:57Z")

</div>

Thanks, I know now the syntax, the id of the card is push\_image, I believe that I need the image token. So I tried to get the token with the command bellow

const myImage = await Homey.images.getImage({id:‘enter\_my\_image\_id’})

But get the error about missing scope and no access error message.

My script looks like

```auto
Homey.flow.runFlowCardAction({
        uri: 'homey:manager:mobile',
        id: 'push_image',
        args: 
        {
			    user: 
            {
			        athomId: 'my user id'
		    	  },
		      text: 'Test push notification'
        },
        droptoken: 
        {
          image: 'id of my images'
        }

```

the script runs but no notifictions received, when i change the type to push\_text I get the notification on my mobile. Does some if it is possible to use the push\_image from script and how it needs to setup?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [November 13, 2022, 8:02am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/8 "2022-11-13T08:02:08Z")

</div>

You can send it in a flow right?  
And you can start a flow from HS.

---

<div class="post-metadata">

**Author:** ![Marijn\_Hilbrink](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/marijn_hilbrink/32/55855_2.png) [@Marijn\_Hilbrink](https://community.homey.app/u/Marijn_Hilbrink)\
**Post date:** [November 13, 2022, 10:59am UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/9 "2022-11-13T10:59:18Z")

</div>

Yes that works fine, I want to speed things up. My flow runs a script, I set some variabel and based on that the flow send the push notification. The flow runs every 5 seconds, I can see that the flow will take some while waiting for the script finished. I think on this moment I cannot be done, no big deal. But if someone knows how please let me know.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [November 13, 2022, 3:13pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/10 "2022-11-13T15:13:43Z")

</div>

Well, all flowcards can be simulated through HS. Am sure of that.  
But, im not sure you can get the image (ID) that you need.  
Im willing to take a look tomorrow or at least this week.

The WebApi/developer page shows all images, so there is some way of getting the image (id) (which you will need for the card or you would need have access to a real/binary file in HS?).

---

<div class="post-metadata">

**Author:** ![MNA](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mna/32/17266_2.png) [@MNA](https://community.homey.app/u/MNA)\
**Post date:** [March 1, 2023, 8:03pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/11 "2023-03-01T20:03:57Z")

</div>

Hi Peter, Don’t know if you found out, but the reason that it always results in Yes is that you have a return(true) as the last line. If you use return(response.result) instead then you will get a Yes or No.

---

<div class="post-metadata">

**Author:** ![Kringloper](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/kringloper/32/70714_2.png) [@Kringloper](https://community.homey.app/u/Kringloper)\
**Post date:** [July 15, 2023, 12:44pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/12 "2023-07-15T12:44:06Z")

</div>

Found this topic because i can’t find an option within Homey to send a push message to te last person leaving the house. I am using smartPresence and within the flow i get the username. So, i thought to solve it by modifying this script.

But, i never came that far, because the script isn’t sending a push message at all. With the standard action flowcard i can send push messages. So pushmessages is working. I tried it by just running the script as a test and by using a actionflowcard with running this script. I also entered my athomID.

Maybe i’m on the wrong track.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/c/8ceed47f7c8c049655b5827d8c252cf4686ac0e6.png)

Without the await, i don’t get an errormessage. By the way i’m using a Homey '23

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 15, 2023, 3:33pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/13 "2023-07-15T15:33:38Z")

</div>

> [@Sending notification will not work in Homeyscript](https://community.homey.app/t/sending-notification-will-not-work-in-homeyscript/79235/8):
>
> On HomeyPro early 2023 version 10.0.0-rc.122, I found it necessary to give both “athomID” and “id” parameters for a successful push\_text. Example code: // Tested using versions: // - Homey Pro (Early 2023), version 10.0.0-rc.122 // - Homey Web App version 1.9.58 // Status as of 15-July-2023: working // send message to specified user, or if none specified, then first user in getUsers list var user\_name = (typeof args[0] === 'string') ? args[0] : ''; var user\_athom\_id = null; var user\_id …

---

<div class="post-metadata">

**Author:** ![Volleyoghurt](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/volleyoghurt/32/3844_2.png) [@Volleyoghurt](https://community.homey.app/u/Volleyoghurt)\
**Post date:** [August 16, 2023, 6:36pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/14 "2023-08-16T18:36:14Z")

</div>

I had a work around.

Step 1:  
Make a flow with a notification to your phone.

Step 2: go to [Homey Developer Tools](https://tools.developer.homey.app/tools/api-playground)  
And log in.

Step 3: type: Homey.flow.getFlows();

Step 4: search the flow with search function of your browser.

Step 5: extract the “Actions” everything you will need is in that field.

Step 6 :use await Homey.flow.runFlowCardAction()

```auto
await Homey.flow.runFlowCardAction({
 uri: "homey:manager:mobile",
  id: "push_text",
  args: {
      user: {
        name: '<name>',
        id: '<ID>,
        image: '<info of image>',
        athomId: '<Athomid>'
      },
      text: '<Text or variable here>'
      }
});

```

If you use a function, don’t use await.  
use the ’ ’ and not the " ".

Good luck.

Greetings

---

<div class="post-metadata">

**Author:** ![M\_J](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/m_j/32/81222_2.png) [@M\_J](https://community.homey.app/u/M_J)\
**Post date:** [June 2, 2024, 3:18pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/15 "2024-06-02T15:18:00Z")

</div>

Do you know how i set this up in a normal advanced flow? (dutch) I have adding questionmark and ‘verzoek’ at the beginnen of the pushmessage, but i can’t get the question when recieving the notification?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [June 2, 2024, 5:35pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/16 "2024-06-02T17:35:12Z")

</div>

> Normal advanced flow

for a standard flow or for an advanced flow?  
I’ll show both.

Standard flow:  
With the code below, you can save it as script, and run the script as AND condition, just like you would do with the normal Push confirmation flow card

> ![Screenshot from 2024-06-02 19-36-29](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/2/c28a9bbda7a01e3148d9294a67621e182cde609b.png)

Code:

```auto
// push confirmation
// to retreive the user ID and Athom ID, open this site
// https://tools.developer.homey.app/tools/api-playground
// and run the line:
// Homey.users.getUserMe();

const response = await Homey.flow.runFlowCardCondition({
        uri: 'homey:manager:mobile',
        id: 'homey:manager:mobile:push_confirm',
        args: {
			    user: {
			    athomId: 'your_athomid_here',
                id: 'your_id_here'
		    	},
		    text: 'Test push confirmation from HomeyScript, now choose Yes to confirm; for No, just ignore this:'
        },
      });
  log (response);    
  return(true);

```

Advanced flow:  
You can use the Homeyscript AND card “Run code”, and paste the code above in that card

> ![Screenshot from 2024-06-02 19-27-12](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/d/8dfda45cdd3439b731741912a45fd369363dcbd7.png)

This is an example of what the webapi playground returns:

> ![Screenshot from 2024-06-02 19-22-44](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/8/785d324e5f272ab3e73149f8d18edfcdb8cf66e0.png)

---

<div class="post-metadata">

**Author:** ![M\_J](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/m_j/32/81222_2.png) [@M\_J](https://community.homey.app/u/M_J)\
**Post date:** [June 2, 2024, 5:43pm UTC](https://community.homey.app/t/how-to-send-a-push-confirmation-from-homeyscript/68704/17 "2024-06-02T17:43:34Z")

</div>

Thank you, i’m new with the scripting, but i will take look for it 👍  
I normally only use the standard cards in the homey web portal
