Advanced Features
Scripting and Custom Code
Learn how to extend the functionality of your Wayvo applications using scripting and custom code.
Scripting and Custom Code
Wayvo provides powerful scripting capabilities that allow you to add custom logic and extend the functionality of your applications. You can use TypeScript and Python to write scripts that interact with your application's components, data sources, and external services.
Adding Custom Scripts
Access the Script Editor
- Navigate to the "Scripts" section from the main menu.
Create a New Script
- Click on "Create New Script" to open the script editor.
- Choose the scripting language (TypeScript or Python) for your script.
Write Your Script
- Use the script editor to write your custom logic.
- Take advantage of the built-in code completion and syntax highlighting to write scripts efficiently.
Save and Deploy
- Save your script and deploy it to make it available for use in your application.
Using Scripts in Your Application
Bind Scripts to Components
- In the properties panel of a component, navigate to the "Events" section.
- Bind your script to an event (e.g., onClick, onLoad) to execute the script when the event occurs.
Integrate Scripts with Workflows
- Add script actions to your workflows to execute custom logic as part of your automated processes.
- Use the workflow designer to define when and how scripts should be executed.
Accessing Application Data
Querying Data Sources
- Use scripts to query data sources and retrieve information.
- Utilize the provided APIs to interact with databases, APIs, and other data sources.
Manipulating Data
- Write scripts to manipulate data within your application.
- Perform operations such as filtering, sorting, and transforming data.
Working with External APIs
Making API Calls
- Use scripts to make HTTP requests to external APIs.
- Include necessary headers, parameters, and payloads in your requests.
Handling API Responses
- Process and handle API responses within your scripts.
- Use the response data to update your application's state or trigger other actions.
Error Handling in Scripts
Try-Catch Blocks
- Use try-catch blocks to handle errors in your scripts.
- Provide fallback logic or error messages to handle unexpected situations.
Logging Errors
- Log errors to help with debugging and monitoring.
- Use Wayvo’s logging tools to track and analyze script errors.
Debugging Custom Code
Using the Debugger
- Utilize the built-in debugger to step through your code and identify issues.
- Set breakpoints and watch variables to monitor the execution flow.
Viewing Logs
- Access the log viewer to see detailed logs of your script executions.
- Use the logs to troubleshoot and resolve issues.
Best Practices for Scripting
Keep Scripts Modular
- Write modular scripts that perform specific tasks.
- Reuse scripts across different components and workflows to maintain consistency.
Document Your Code
- Include comments and documentation in your scripts to explain their purpose and functionality.
- This helps other developers understand and maintain the code.
Optimize Performance
- Optimize your scripts for performance to ensure they run efficiently.
- Avoid unnecessary computations and optimize data processing logic.
Tip!
Use scripting and custom code to add advanced functionality and create dynamic, interactive applications that meet your specific requirements.
Next Steps
With your custom scripts in place, you can further enhance your applications by integrating them with other Wayvo features. Explore our guides on Workflow Automation and Integration with External Services to continue building powerful and efficient applications.
For more advanced customization options, check out our Advanced Features section.