# Send data from your chatbot to pre-fill a webpage

Using our JavaScript API method, collectchat.on
[https://developers.collect.chat/#/callbacks?id=collectchatonevent-function],
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 [https://demos.collect.chat/completed-data/].





Note



These 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
[https://developers.collect.chat/#/callbacks?id=collectchatonevent-function] 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 chatbot 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.