How to collect and store data with your chatbot?

data collection bot
data collection bot

Published by:

Eran Soroka

We all have a memory. We remember names, faces, numbers, addresses, tastes. Bots have memory too: Everything that is written or said by a user in a conversation is recorded in the bot’s log. It enables you to improve the conversation, but also to collect information that is important for your goal and for making the most out of your chatbot. So today, we’ll build a data collection bot together.

The pieces of information the user provides are called “inputs”.

Let’s say that you run a website for Classic Rock bands merchandise, and you want to know what’s your user’s favorite rock band to be able to offer them the coolest T-Shirts and caps. When you build a chatbot, you can have any conversation you want, but in the end, you’ll need basically two things:

  • The user’s details – let’s say, home address in this case
  • To know what is his favorite rock band

These inputs – pieces of info – will be written by the user into the chatbot’s “memory”. 

Some of them are already included in our conversational components, so you don’t even need to create them. So… let’s get to work!

1. How do you find an input?

Let’s say that you used the “Address” component to get a user’s home address – It collects the address for you, so you don’t have to write anything!

how to save input 1

So how do you know how the input that was collected is called?

  • In the right lower corner, test your chatbot
  • After you confirm the input to the chatbot, it’s in the chatbot’s memory
  • Hover with the mouse over the testing area
  • A little “Bubble” will appear, with the input’s name and the details you gave it

save input 2

This is the input’s name! Write it down, we’ll need it later. This input, for example, is called “userHomeaddress.full

Now, let’s say that you want an input that doesn’t exist in the system yet, such as “user’s favorite rock band”. Let’s go for it!

2. How do you create an input?

  • Choose a “Say” node from the menu
  • Write in it a question that serves your chatbot’s purpose (let’s say, “Now, what’s your favorite rock band?”)
  • Choose a “Navigation” node from the menu
  • Connect a line starting from the previous “Say” to the Navigation node 
  • Choose a “Save input to context” node from the menu and connect the Navigation node to it
  • Write your input’s name inside the inspector on the right (for example, “rockband”).

save input 3

  • Now, the input’s name will appear on the node itself.

save input 4

Now, what happens? The chatbot asks the visitor “what’s your favorite rock band?”; the user answers; you get the input. Bang! Your data collection bot is warming up.

3. Can I save a user’s response (input) under another name?

Yes. Let’s assume that a lot of users love the band Guns n’ Roses. But some of them write their name GnR or Guns and Roses, for example. And since the bot spoke with thousands of people who can have different iterations of the same phrase, you need to have only one output for all the different ways of saying or writing the same phrase. So, how do you manage that?

  • Create an intent with all the main ways or phrases that mean the same for you. You can use a “learned intent” to allow for some extra grammar mistakes.

save input 5

  • Choose a “Save params to context” (not the “save input” one) node from the menu and connect the Navigation node to it
  • Write your input’s name under “save us” inside the inspector on the right (for example, “rockband”), AND – under “save value”, write the name in which you want the input to be saved, no matter how the user wrote it

save input 6

And here it is in the “bubble”:

save input 7

Now, although the user wrote “guns n roses” instead of “guns n’ roses” – we still got it right, as you see in the black bubble.

The same logic applies, for example, when you ask a person for his favorite food and want to enlist all kinds of vegetables under “vegetable”, or all cities in France under “French cities”.

4. How can I use the input I’ve collected with my data collection bot?

As mentioned above, the user’s response – input – is now saved into the conversation’s context. To use it, we just need to type in this thing:

${context.????} – this is the way to use, or recall, a component.
  • The “context” means that we want to use the input as part of the conversation’s context
  • The ???? is the name of the input you just did in part 1, like “rockband”
  • So what do you need to write here to use it? Right, ${context.rockband}
  • The chatbot will “remember” the user’s input and will replace this formula with the band’s name from now on.

For example, you can continue the flow about Guns N’ Roses by telling the users in a say:

${context.rockband}? Wow, welcome to the jungle!

save input 8

Cool, right? Now to the final part – storing the data.

5. How can I email myself (or anybody else) the data I’ve collected?

  • Choose a “Send email” component and connect it to the most recent open part of the flow
  • In the right part of the screen, enter your email address, the email’s subject (headline), and the email’s content (body)
  • In the email’s body, write yourself an email and recall all the inputs you want

save input 9

After the bot concludes a chat, you’ll get an email looking like this:

save input 10

To see all the conversation, you can also add this line to the email’s body:

${conversation_log}

And then you’ll get this nice addition to your email

Your data collection bot is ready!

Want to integrate the data you’ve collected into a Google Spreadsheet? Click here to see our step-by-step guide.

Other guides from cocohub: