# Add custom data in your chatbot response

You can include custom data with user responses. The custom data may come from
URL or it may be generated based on any action on the page and then passed down
using JavaScript.



If you are looking to add the URL parameter data inside the conversation, please
refer this article.
[https://collect.chat/help/article/1122-add-data-from-url-parameters-inside-a-conversation]


ADD URL PARAMETERS IN SETTINGS

Let's say your URL is

https://yourwebsite.com/?name=amy&userid=AOJ843

Here you have two pieces of information, name and userid that need to be sent
along with the chatbot response. Both URL parameters are known to you. In this
case, you can pass these URL parameters to the chatbot using custom fields.



Go to Settings of your chatbot, then click on Data Collection. Click on add
custom field button and provide the parameters as custom fields. Here you will
be adding two keys, name and userid.



Once they are defined in the settings, the chatbot will be able to pick it up
and send it along with the rest of the conversation that user had with the
chatbot. You will be able to see these data points in the response section as
well as in the email notifications [/article/1019-email-notifications].



Note



Passing URL parameters to the chatbot works only when the chatbot is used in
widget mode
[https://collect.chat/help/article/1004-how-to-add-chat-widget-to-website] and
when used in link mode
[https://collect.chat/help/article/1006-use-your-interactive-form-as-a-landing-page].
It will not work in Embed mode. For embed mode we suggest the following method
given below.


ADDING DATA USING JAVASCRIPT

You can pass the custom data like the user's email which is available in your
web app using our Javascript API
[https://developers.collect.chat/]'s collectchat.set
[https://developers.collect.chat/#/custom?id=collectchatsetkey-value] method.
Here also, you have to set these keys in Settings > Response of your chatbot,
like above. An example code:

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    collectchat.set('email', 'email@user.com');
    collectchat.set('country_code', 'US');
}
</script>




Note



This code will work on both Widget and Embed mode. Please see How to enable
developer options when the chatbot type is Embed?
[/article/1139-how-to-enable-developer-options-when-form-type-is-embed] for more
information.