We all love to automate certain tasks right ? but sometimes you find Alice is missing a minor feature that you’re looking for. Like automagically go into “Good night”" mode at a certain time of the night and then say “Ggod morning” at a certain time in the following morning.
Suggestions are always welcome but we can’t always action them immediately. Alice continues to grow and some weeks, quite rapidly, but perhaps your personal touch can be achieved using Node red in the meantime ?
At the moment Node Red is also one of those items growing with time. However sending Alice a good night message for example is still in the production line. But in the meantime i’ve created a flow you can import into Node red that will, in this case… send a good night message when you click the inject button. However with a few tweaks you can trigger what ever intent you like. I’ll leave that up to your imagination 😼
New to Node Red ? I’ll give some quick steps to that further down this post. Otherwise want to get straight into it ? Then copy this following flow and “import” it into your “senarios > Node Red”
If you can read comment nodes then click the comment node on the flow for instructions. If you can’t then read the same description on the “inject node” (single click inject node then the “ i ” button top right of the Node Red screen )
basically though …
- import the flow
- change the “set the message” node to what ever intent you want to trigger
- click “inject ” button , ()Alice in this flows case will say good night to you).
COPY THIS FLOW
[{"id":"284952eb.e4a106","type":"tab","label":"Send a Action","disabled":false,"info":""},{"id":"3af3b1d6.db3dbe","type":"inject","z":"284952eb.e4a106","name":"<-- click to start a session","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{}","payloadType":"json","x":170,"y":40,"wires":[["4257c68.eae8738"]],"info":"In order for this flow to work.\n\n1. Edit the node titled \"set the message\" and replace \"good night\" with the message of your choice. \n- No need to edit the seconds property of that node. Just leave it at 1\n\n2. if either the purple nodes or the blue Alice node don't say \"connected\" once the flow is deployed then please setup your mqtt details in each node. Currently they are set to localhost so it should \"just work\" :)\n\nTo Operate :\n\nClick the inject node to action the event. Or make it more useful by setting the inject node to trigger at a specific time ( refer the repeat drop box in the inject node) or maybe a onAlice event node to trigger when something happens. The choices are endless :)\n\nNOTE: The flow trigger function sets a variable so that your flow doesn't get triggered everytime you verbally start a session with Alice. It allows this flow to process ONLY if this flow was the one triggering the session. There is no need to edit the function node unless you double up this flow on the same tab. In which case you will then need to set the varibale to something like flowTrigger1 (refer function node description for more info )"},{"id":"77c6ad89.fd28fc","type":"mqtt out","z":"284952eb.e4a106","name":"","topic":"hermes/dialogueManager/startSession","qos":"","retain":"","broker":"2ffe375e.62495","x":570,"y":100,"wires":[],"info":"Set your broker details to Alice's MQTT broker"},{"id":"e0b40988.45e0a","type":"change","z":"284952eb.e4a106","name":"Set the Message","rules":[{"t":"set","p":"payload.text","pt":"msg","to":"good night","tot":"str"},{"t":"set","p":"payload.seconds","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":320,"wires":[["34da9b63.fc7bb4"]],"info":"Set the message you want sent.\n\nIE : Replace the \"good night\" for the message of your choice \n\nNOTE: The seconds property is required. But just leave that as 1 second as its not important"},{"id":"8bfaa532.80761","type":"comment","z":"284952eb.e4a106","name":"Please read for setup Instructions","info":"In order for this flow to work.\n\n1. Edit the node titled \"set the message\" and replace \"good night\" with the message of your choice. \n- No need to edit the seconds property of that node. Just leave it at 1\n\n2. if either the purple nodes or the blue Alice node don't say \"connected\" once the flow is deployed then please setup your mqtt details in each node. Currently they are set to localhost so it should \"just work\" :)\n\nTo Operate :\n\nClick the inject node to action the event. Or make it more useful by setting the inject node to trigger at a specific time ( refer the repeat drop box in the inject node) or maybe a onAlice event node to trigger when something happens. The choices are endless :)\n\nNOTE: The flow trigger function sets a variable so that your flow doesn't get triggered everytime you verbally start a session with Alice. It allows this flow to process ONLY if this flow was the one triggering the session. There is no need to edit the function node unless you double up this flow on the same tab. In which case you will then need to set the varibale to something like flowTrigger1 (refer function node description for more info )","x":250,"y":160,"wires":[]},{"id":"4257c68.eae8738","type":"function","z":"284952eb.e4a106","name":"Sets a flow variable","func":"var flowTrigger=(flow.get(\"flowTrigger\") || 0);\n\nflow.set(\"flowTrigger\",1);\n{\n return msg;\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":390,"y":40,"wires":[["77c6ad89.fd28fc"]],"info":"If you use this flow multiple times in the one flow then you will need to change the varibale name from flowTrigger to something like flowTrigger1 as you will need a different varible name for each instance.\n\nHowever if you use this flow in another flow there is no need to change the value as its flow sensotive (relevant only to the current flow)"},{"id":"32fbb104.92ffbe","type":"debug","z":"284952eb.e4a106","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":430,"y":400,"wires":[],"info":"I'm just here to show you the payload in the debug screen to the right :)"},{"id":"34da9b63.fc7bb4","type":"function","z":"284952eb.e4a106","name":"Resets flow trigger","func":"var flowTrigger=(flow.get(\"flowTrigger\") || 0);\n\nif (flowTrigger === 1)\n{\n flow.set(\"flowTrigger\",0);\n return msg\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":230,"y":400,"wires":[["878a85ab.dba308","32fbb104.92ffbe"]],"info":"If you use this flow multiple times in the one flow then you will need to change the varibale name from flowTrigger to something like flowTrigger1 as you will need a different varible name for each instance.\n\nHowever if you use this flow in another flow there is no need to change the value as its flow sensotive (relevant only to the current flow)"},{"id":"878a85ab.dba308","type":"sendMsg","z":"284952eb.e4a106","broker":"3a2327ac.6c614","topic":"hermes/asr/textCaptured","x":490,"y":460,"wires":[]},{"id":"a2a5fc0.104e488","type":"mqtt in","z":"284952eb.e4a106","name":"","topic":"hermes/dialogueManager/sessionStarted","qos":"2","datatype":"auto","broker":"2ffe375e.62495","x":260,"y":240,"wires":[["36d58005.01d7"]],"info":"Set your broker details to Alice's MQTT broker"},{"id":"36d58005.01d7","type":"json","z":"284952eb.e4a106","name":"","property":"payload","action":"","pretty":false,"x":530,"y":240,"wires":[["e0b40988.45e0a"]],"info":"This converts the incoming object to json format so we can modify it's properties in the next node"},{"id":"2ffe375e.62495","type":"mqtt-broker","name":"Alice","broker":"localhost","port":"1883","tls":"","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"3a2327ac.6c614","type":"aliceMqtt","broker":"localhost","port":"1883","tls":"","usetls":false}]
New to Node Red ? don’t know how to import ?
go to
- Alices web interface
- Senarios tab
- Let Node red load up
- In Node red … top right of the window click the 3 bars (burger menu)
- Choose import
- Paste the above flow into there and click ok
Enjoy 🙂