Advanced Action Flows – Part 2. Customized messages to each geofence

In this tutorial, we are going to learn how to send customized push messages to different geofences. We are going to have 4 geofences and we will send each of them a custom message. In our example, the geofences are called Shop, Gym, Library and Museum. Be careful with capitals.


  • Add the geofences on the portal.
  • Login to the management app or use your own app to get the push messages sent.

Step 1 : Import the following piece of code into the action flow clipboard from top right corner.

[{"id":"23ae0f0d.17e58","type":"function","z":"1b96df89.99585","name":"Gym Push","func":"return {\n    type: 'push',\n    title: 'Have a great workout!',\n    _proximi_id: msg._proximi_id,\n    _proximi_visitor_id: msg._proximi_visitor_id\n}","outputs":1,"noerr":0,"x":411,"y":241,"wires":[["ffed6b4a.96bc88"]]},{"id":"1c56b30c.34558d","type":"switch","z":"1b96df89.99585","name":"Check Event Type","property":"event","propertyType":"msg","rules":[{"t":"eq","v":"enter","vt":"str"},{"t":"eq","v":"exit","vt":"str"}],"checkall":"false","outputs":2,"x":155,"y":190,"wires":[["faac667d.769388"],[]]},{"id":"5c0a8316.23badc","type":"proximiio-event-receiver","z":"1b96df89.99585","delete_event":true,"x":115,"y":90,"wires":[["1c56b30c.34558d"],[]]},{"id":"55a79e12.ed7bd","type":"function","z":"1b96df89.99585","name":"Shop Push","func":"return {\n    type: 'push',\n    title: 'Bananas on sale today!',\n    _proximi_id: msg._proximi_id,\n    _proximi_visitor_id: msg._proximi_visitor_id\n}","outputs":1,"noerr":0,"x":406,"y":160,"wires":[["ffed6b4a.96bc88"]]},{"id":"ffed6b4a.96bc88","type":"proximiio-event-transmitter","z":"1b96df89.99585","x":737,"y":241,"wires":[]},{"id":"ebc8cbb7.a45238","type":"function","z":"1b96df89.99585","name":"Museum Push","func":"return {\n    type: 'push',\n    title: 'This is an Etruscan vase!',\n    _proximi_id: msg._proximi_id,\n    _proximi_visitor_id: msg._proximi_visitor_id\n}","outputs":1,"noerr":0,"x":414,"y":463,"wires":[["ffed6b4a.96bc88"]]},{"id":"3531b9df.083906","type":"function","z":"1b96df89.99585","name":"Library Push","func":"return {\n    type: 'push',\n    title: 'Need help finding a book?',\n    _proximi_id: msg._proximi_id,\n    _proximi_visitor_id: msg._proximi_visitor_id\n}","outputs":1,"noerr":0,"x":410,"y":337,"wires":[["ffed6b4a.96bc88"]]},{"id":"faac667d.769388","type":"switch","z":"1b96df89.99585","name":"Check Geofence ","property":"data.geofence","propertyType":"msg","rules":[{"t":"eq","v":"Shop","vt":"str"},{"t":"eq","v":"Gym","vt":"str"},{"t":"eq","v":"Library","vt":"str"},{"t":"eq","v":"Museum","vt":"str"}],"checkall":"true","outputs":4,"x":156,"y":314,"wires":[["55a79e12.ed7bd"],["23ae0f0d.17e58"],["3531b9df.083906"],["ebc8cbb7.a45238"]]}]


Step 2 : The action flow should look like this:


Here’s the full walk-through of each of the steps and what’s happening in the action flows: Event Receiver
This node listens for visitors entering or exiting any of the defined geofences. When a proximity event occurs, the node get’s triggered and it will pass all the event data as an output payload.

Switch node
A Switch node can be used to segment the action flow based on the event type, department and a lot of other properties as well. You can check out all the properties from our REST API documentation. In this case we’re reacting only to “enter” events.

Switch node #2
Another Switch node will be used to determine, which geofence was entered. Change the name of the geofences to match with the ones created by you. Double click on “Check Geofence” switch node and change the four entries as to match with your names. You can also leave this node empty in order to deliver the message to all geofences.

Function node
Function node allows you to use JavaScript to add custom logic which might not be possible with other nodes. One of the ways to use the Function node is for push messages. native SDK’s include a helper that will show a local push notification when it receives a payload with type: ‘push’. Double click the node to change its content. Ensure the order of the push messages are same as the order of geofences in the previous Switch node.

push_banana Event Transmitter
Event Transmitter sends a payload to the visitor’s device. Node requires _proximi_id and _proximi_visitor_id to be present in msg object which are present in every received event from Event Receiver.

Step 3: Deploying the action flow :

You can deploy the action flow from the top right corner of the editor. Usually it’s good idea to select the first option “Full”.

Deploying the action flow

Pro tip:

If you have dozens or hundreds of geofences and want to manage them and their messages really easily,  you can utilize the geofence name as a part of the push message. For example: “Welcome to the grocery store!”, where “grocery store” is the geofence’s name. You can get the geofence name into the flow through In fact, anything available through the REST API may be used similarly in the flows.

The flow will be much simpler in that case. Just copy and import the snippet below:
[{"id":"de77f6c9.4b0378","type":"proximiio-event-receiver","z":"1b96df89.99585","delete_event":true,"x":120,"y":58,"wires":[["ebeaea0d.093798","e303a061.d0ef9"],[]]},{"id":"3f8866fb.cc019a","type":"function","z":"1b96df89.99585","name":"Example push notification","func":"return {\n    type: 'push',\n    title: 'Have fun at ' + + '!',\n    _proximi_id: msg._proximi_id,\n    _proximi_visitor_id: msg._proximi_visitor_id\n}","outputs":1,"noerr":0,"x":464,"y":220,"wires":[["ede9ccf0.4ba18"]]},{"id":"ede9ccf0.4ba18","type":"proximiio-event-transmitter","z":"1b96df89.99585","x":724,"y":180,"wires":[]},{"id":"e303a061.d0ef9","type":"debug","z":"1b96df89.99585","name":"Debug the event","active":true,"console":"false","complete":"true","x":379,"y":82,"wires":[]},{"id":"ebeaea0d.093798","type":"switch","z":"1b96df89.99585","name":"Check the event type","property":"event","propertyType":"msg","rules":[{"t":"eq","v":"enter","vt":"str"},{"t":"eq","v":"exit","vt":"str"}],"checkall":"false","outputs":2,"x":271,"y":160,"wires":[["3f8866fb.cc019a"],[]]}]

About Annina Koskiola

CEO and Co-founder of Loves exploring new ways for technology to intertwine with our everyday lives. Passion for history, traveling, eating and the Valais Blacknose sheep.