Example Solutions
Page Objective
This solutions page provides detailed configuration guidance for each element added to the scenario. At every step, you can click on the "Check the configuration for this step" link to verify that your setup is correct.
Basic Example
Calendar Node Configuration
Execution Tab

Schedule Tab

- Note: Make sure to use 0 for seconds and minutes!
Speak Node Configuration

- Listening resumes after the TTS on the client.
- Use the
Test...button to test the TTS.
Activating the Scenario

- Scenario activation is performed in the
Calendarnode.
Adding an Action Node
Delete the Edge
- Delete the edge between the
Speaknode and theendnode: -
Left-click on the edge.

-
Add an
Actionnode in the editor. - Rearrange the nodes to format the layout.
- Click on the parent node
Speakand then on the child nodeAction. - Click on the parent node
Actionand then on the child nodeEnd. - The edge will be created.
Modifying the Speak Node

- The new
Actionnode must be executed after the complete vocalization of the TTS. - Tip: Check the box
Wait for TTS to finish...
Configuring the Action Node

- Enter a name for the action (e.g.,
getWeather). - Select the client that sends the task.
- Leave the "client executing the task" selection empty (the executing client will be the same as the sending client).
- Choose the
Meteomaticsplugin. - Modify the
languageparameter to the appropriate language code (for example, 'fr'). - Modify the
commandparameter to call the function to be executed.
How to Modify the command Parameter
Let's examine what the meteomatics plugin needs for the function to be executed:
- Open the meteomatics.js file from the
meteomaticsplugin in your favorite editor. - Locate the
actionfunction. -
The weather call is made using:
- The parameter
data.action.command - The key
getWeather - The parameter
data.client
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
export async function action(data, callback) { try { Locale = await Avatar.lang.getPak("meteomatics", data.language); if (!Locale) { throw new Error (`meteomatics: Unable to find the '${data.language}' language pak.`); } // Table of actions const tblActions = { getWeather : () => getWeather(data.client, data.action?.byScenario, callback) } info("meteomatics:", data.action.command, L.get("plugin.from"), data.client); // Calls the function that should be run tblActions[data.action.command](); } catch (err) { if (data.client) Avatar.Speech.end(data.client); if (err.message) error(err.message); } if (!data.action?.byScenario) callback(); }Important
The node automatically creates a
data.actionobject and adds all the parameters specifically created for the plugin into this object. All these parameters will be available to the plugin viadata.action(e.g.,data.action.command). - The parameter
-
Add
getWeatherto thecommandparameter so that it conforms to what must be sent to the plugin. -
There is no need to check the
Wait for the action to complete...box since this is the last node to execute. -
Click the "Test..." button to test the command.
Modifying the Action Node

-
Add the
byScenarioparameter so that the execution order is preserved.
(Refer to the Wait for the action to complete chapter for more information.) -
Check the
Wait for the action to complete...box.
Adding a New Branch
Configuring the Calendar Node
Execution Tab

- Check
By voice rule. - Check
Enable the rule.
Rule Tab

- Add the rule
stop * alarm clock. - Use the
Translateicon to convert the text into English if needed.
Configuring the Javascript Nodes
To verify if the scenario is active, there are several possibilities.
The simplest is to test a variable that we can add to the global Config object, named Config.scenarios["alarm clock"].enable, and then add a check in the Javascript function.
Since this variable does not exist yet, first modify the programmed branch of the scenario that triggers the alarm to add the configuration of this variable.
- Add a
Javascriptnode in the programmed branch between theCalendarnode and theSpeaknode. -
Name the action
setAlarmVarand add the following code to define the variable:1 2 3 4 5 6 7
async function setAlarmVar(payload, state){ Config.scenarios = { "alarm clock": { enable: true } }; }
Expected result:

-
Configure the
Javascriptnode in the new branch to test the variable.1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
async function isAlarmEnabled(payload, state){ if (Config.scenarios && Config.scenarios["alarm clock"] && Config.scenarios["alarm clock"].enable === true) { // Set the parameter to false to stop the loop // of all mp3 files Config.scenarios["alarm clock"].enable = false; // Stop the music Avatar.stop(state.client); } }