# How to run global command based on user typing input
Global command can be called from any JavaScript code execution. Every input component in Request Response step has switch "Use function to define user answer" that allows to execute JavaScript code before user answer will be sent. It was created to check user input and change it somehow or run custom logic.
- Add Process Global Command (RWC) step
- Add new command and type 'agent'
- In Request Response step chose Text and Files input component and enable "Use function to define user answer" toggle
- In User answer message add a code, that will check whether user reply matches with global command name.
if (userReply.includes('agent')) {
window.runGlobalCommand({name: 'agent'})
return null
}
return userReply
WARNING
You have to return null to prevent message sending
- If user answer contains 'agent' then global command will be triggered and flow goes by 'agent' leg