Categories

Categories

Send data from chatbot to pre-fill a webpage

Send data from chatbot to pre-fill a webpage

Using our JavaScript API method, collectchat.on, you can now send the data captured by the chatbot to a different page and pre-fill it. This is useful if you want to create a booking or accept a payment using the chatbot as the first interface and then redirect your users to the booking/payment page with all the data filled in.
 
Here is a demo of the same.
 
Note
This steps described here might be a bit technical for non-developers. We recommend consulting a developer from your team to proceed with this integration.

Send the data

When the conversation gets completed, the callback collectchat.on will be triggered for the "complete" event. Here, the parameter list, will contain the conversation details up to that point in the conversation. It is an array of questions and answers.
Now you can send these answers from the bot by means of URL parameters. For example:
<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.on('complete', function(list) {
        console.log('User just completed the conversation', list);
        var name =  list[1].answer;
        var email =  list[2].answer;
        var feedback = list[3].answer;
        window.location = './page.html?name='+name+'&email='+email+'&feedback='+feedback;
    });
}
</script>

Accept the data

You can now accept the data that is encoded in the URL and programmatically decide how the page should be pre-filled.
 


Still need help?

Contact us