When a user clicks a button, JavaScript runs on the client
To set up this Global action:
- Add the Step name to the Set up Global Actions (RWC) Step.
- In the Step, click + Add custom action.
- In Process as, select Button from the dropdown.
- Choose the button icon from Google Material Icons. In Icon, write its name from the website in the snake case. For example,
shopping_cart
. The integration will upload the icon to the RWC client. - In Lable, write the button label the user will see in the chat when hovering the button icon.
- In Action type, select JavaScript code from the dropdown.
- In Code, write your script.
- Save and activate the Flow.
Result
When the Flow reaches the Set up Global Action (RWC) Step, the button becomes available in the chat. Once a user clicks it, the script gets executed on the client, not in the Flow.
To remove or change the existing Global action button
The Flow has the Set up Global Actions (RWC) Step that adds the Global action button to the chat. If at a certain point in the conversation, you want to hide the button from the chat or change how it is processed, override the Step.
Add the second Set up Global Actions (RWC) Step below the first Step further in the Flow. The names of the two Steps can be different. Set up the second Step according to the instructions above, but in Icon and Lable, provide values from the first Step and leave the Code field empty. As a result, when the Flow reaches the second Set up Global Actions (RWC) Step, the button hides from the chat.
Instead of hiding the button, you can also change how it is processed by providing another JavaScript in Code. To change button processing to link opening, select Open URL instead of JavaScript code in Action type.