Tips: Launch
Step-by-step guidance on how to configure and update contact information within your Helply AI agent.
Our widget includes a contact form that allows users to submit their information. To enhance the user experience, you can pre-fill the contact form with the user's email and name by integrating the following code snippet into your website or application. This ensures a smoother interaction and reduces redundant input for your users.
Ensure that the widget is loaded so that the widget api is available on your website or application before attempting to set the contact information. You can do this by checking for the existence of window.helplyAgentWidget.
The setContact method allows you to programmatically set the user's email and name. Below is the JavaScript code snippet to include in your implementation:
if (window.helplyAgentWidget) {
window.helplyAgentWidget.setContact({
email: '[email protected]',
firstName: 'John',
lastName: 'Doe'
});
}
Place this code snippet after retrieving the user's information from your website or application. For example:
fetchUserData().then(user => {
if (window.helplyAgentWidget) {
window.helplyAgentWidget.setContact({
email: user.email,
firstName: user.firstName,
lastName: user.lastName
});
}
});
If your website fetches user details upon login or registration, you can use the setContact method immediately after fetching the data. This ensures that the widget reflects the correct user information as soon as it loads.
If you want to ensure that the widget is fully loaded before performing any actions, you can use the helplyAgentLoaded event. Add the following code to listen for the event:
window.addEventListener('helplyAgentLoaded', handleAgentLoaded);
function handleAgentLoaded() {
console.log('Helply Agent Widget is loaded.');
// Additional setup or actions can go here
}
This is optional and can be useful if your integration setup requires precise control over the widget's loading state.