My SAAS company’s been making good use of Intercom’s ability to pop up the chat widget with a message request prefilled with a request. For instance, we have a button to request that the user’s account is closed (in lieu of the actual functionality existing) – when clicked, an Intercom chatbox opens with the language “please close my account.” This allows my developers to focus on implementing more profitable features alwhile helping the user put in a request without having to type out their request.
Can the Javascript API please be enhanced to include similar functionality?
1 Like
Hello, @double0514
It’s great to hear that your SAAS company is effectively utilizing Intercom’s chat widget for streamlining user requests. Enhancing a JavaScript API to include functionality for a prefilled message in a chat widget can indeed be a valuable feature for both users and developers.
I can suggest a general approach that you might consider. You could use the existing JavaScript API provided by your chat widget service (like Intercom or tawk.to) to programmatically open the chat widget with a prefilled message. Here’s a conceptual example of how you might achieve this:
// Check if the chat widget API is available
if (window.ChatWidgetAPI) {
// Function to open the chat widget with a prefilled message
function openChatWithPrefilledMessage(message) {
window.ChatWidgetAPI.open({
message: message
});
}
// Add event listener to your button
document.getElementById(‘close-account-btn’).addEventListener(‘click’, function() {
openChatWithPrefilledMessage(‘Please close my account.’);
});
}
In this example, ChatWidgetAPI is a placeholder for the actual API object provided by your chat service, and open is a hypothetical method that opens the chat widget with options, including a prefilled message. You would need to replace these with the actual API details provided by your chat service.
If you want more details please tell me I am happy to help you.
Best Regard,
angela683h