Add custom data in chatbot response

Markdown

View as Markdown

You can add custom data along with user answers into response. 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.

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 inform the chatbot of these URL parameters using custom fields.

Go to your Settings > General of your Bot and provide these keys 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.

Note

Passing URL parameters to the chatbot works only when the bot is used in Widget mode and when used in Chatbot page mode. 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 that is available in your web app or website using our Javascript API's collectchat.set method as well. Here also, you have to set these keys in Settings > Response of your Bot, like above. An example code:

<script>
var collectchat = window.collectchat || {};
collectchat.ready = function() {
    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 chatbot is in Embed mode? for more information.



Still need help?

Contact us

Was this article helpful ?

Still need help?

Contact us

General

General

How to create your first chatbot with Collect.chatGoogle Tag ManagerMailChimpShow or Hide the bot based on URLSet up custom domain for chatbot pageEmail NotificationsResponse StatusWhere can I get my Invoice?Facebook PixelSend the data to your server using webhookGoogle CalendarIs there a discount?How to add chatbot to BigCommerceTranslate your ChatbotLogical JumpGoogle SheetsSalesforceMultiple Emails and RoutingFreshdeskIntegromatMy payment has failed, what to do?What is a response?I am getting spam responsesZapierWhat happens when I upgrade or downgrade?LeadsBridgeGoogle AnalyticsWhy am I not getting email notifications?How to add billing address to my invoice?Webhook in my chatbot is not workingThe changes I made to my chatbot are not visibleWhat is your refund policy?Why is my chatbot not showing up on my website?Do you have a trial account?How to add chatbot to WordPressHow to cancel my account?How to add chatbot to Medium BlogsHow to add chatbot to ShopifyHow do you charge us?How to add chatbot to CloudflarePermanently remove my chatbotHow to make the payment?How to add chatbot to NotionCan I use Collect Chat for free?What happens when I cross the response limit?How to add chatbot to Mobile AppHow to add chatbot to WeeblyHow to add chatbot to TumblrHow to add chatbot to SquarespaceHow to add chatbot to WixShare chatbot as a Landing PageHow to add chatbot widget to WebsiteConversational Marketing Chatbots and Collect.chatHow Chatbots work inside a WebsiteHow to embed chatbot in a webpageDesign a conversational landing pageCreate a copy of the botAdd a custom avatarCan I block responses from an IP address?How to add a welcome message to chatbot widget?Add a video from LinkedIn to the chatbotStop saving data on Collect.chat's serverAdd slides from SlideShare inside the chatbotAdd a video to the chatbotCan I customize the speed of the conversation?Validate phone number inside chatbotHow to capture email addresses?Open the chatbot if user is about to leaveShow or Hide the bot based on ReferrerAddress users by name using variablesEdit the chatbot conversationShow or Hide the bot based on LanguageHow to design my chatbot?Add an image to the chatbotShow or Hide the bot based on API parametersShow or Hide the chatbot based on deviceShow or Hide the bot based on CountryShow or Hide the bot based on UTM tagsShow or Hide the bot based on Operating SystemManage the date and time of when bot has to appearHow to target my users?Show or Hide the bot based on browserOpen the chatbot as the user is scrolling downTeam CollaborationShow or Hide the bot for repeating visitorsHow to hide the chatbot for a user who has already given answersOpen the chatbot widget based on a timerRedirect to a URL based on user choiceWhat is a Script Type?Add data from URL parameters inside a conversationWhatsApp typeOpinion Scale TypeAppointment typeFile Upload TypeThank You TypeText Question TypePhone Number TypeSet up custom domain for chatbot pageRange TypeLinks TypeNumber TypeDate TypeMessage TypeRating TypeEmail TypeAdd live chat supportMulti Select TypeList TypeCapture UTM parameters from URLsSend data from chatbot to pre-fill a webpageTrigger chatbot from a Link or ButtonMulti Choice TypeHide welcome message in mobileHide welcome message for repeating visitorsHow can I analyze my data?Load a new chatbot for repeating visitorsHow to edit my personal information?Add custom messages to the conversationTrack your chatbot using custom analyticsAdd custom data in chatbot responseIdentify a user in Email or SMS campaignsDynamic web pages based on user choiceHow to enable developer options when the chatbot type is Embed?Invoke a new chatbot on the same webpageOpen the chatbot instantly on page loadDo you have an API or tools for developers?Can I export my data?Why do I see symbols in my exported CSV?Do you have support for RTL languages?How to accept only business emails?How to get IP address of chatbot userWhat does your Unlimited Plan offer?How to accept payment via the chatbot?In WordPress, how can I embed a chatbot inside a page or a post?In WordPress, how can I add a different chatbot for a different page?How to trigger a bot from a WordPress Menu?In WordPress, how can I control the behaviour of the bot?How to change my email address?Publish the chatbotHow to be an affiliate?How to change metadata for chatbot pageCan we make a messenger chatbot?Are you GDPR compliant?Can I use multiple chatbots on my websites?Where can I see my Bot ID?How to change my password?Hide welcome message everywhereSetup different chatbot on different pages of the websiteTemporarily disable my chatbotRedirect to a page when conversation endsMulti Select and Multi Choice, what's the difference?Copy a MessageHow to add chatbot to WordPressIn WordPress, how can I embed a chatbot inside a page or a post?WhatsApp typeHow to trigger a bot from a WordPress Menu?In WordPress, how can I control the behaviour of the bot?Send the data to your server using webhookIn WordPress, how can I add a different chatbot for a different page?Welcome to the AI-first Help.Center!Welcome to the AI-first Help.Center!