Setting up JS Callbacks with AI Action Buttons
Summary
This article explains how to add a special 'Callback' action button to your agent. This button allows you to execute custom JavaScript code to handle user interactions in a flexible way.
When to Use This
This guide is for when you need to perform a custom action that isn't covered by the standard Email, Phone, or URL button types. Use a callback button to integrate with your own site's JavaScript functions, trigger specific application events, or create unique user interactions.
Step-by-Step Instructions
- Navigate to the agent settings and open the Popup Settings section.
- Click the + Add action button.
- Select Callback from the dropdown list of button types.
- Enter descriptive text for your button in the Button text field that appears (e.g., 'Request a Callback').
- A code editor will appear, pre-filled with a JavaScript function. You will add your custom code inside this function.
Common Questions (FAQs)
Q: What is a 'Callback' button? A: A callback button is an interactive element that, when clicked, runs a piece of custom JavaScript code that you provide.
Q: Can I change the name of the button? A: Yes, you can set any name for the button by typing it into the 'Button text' field.
Q: What happens after I select 'Callback'? A: The system will automatically generate a template for a JavaScript function where you can write your custom logic.
Troubleshooting Tips
- Issue: The code editor does not appear after selecting 'Callback'.
- Solution: Refresh the page and try adding the callback button again. Ensure there are no browser console errors that might be interfering with the page's scripts.
- Issue: I can't see the 'Callback' option in the dropdown.
- Solution: This feature might be restricted based on your subscription plan or user permissions. Contact your administrator to ensure you have access to this functionality.
