Knowledge Center next icon How do I capture input from the customer and reuse it in a conversation?
Nov 19, 2024
3 minutes read

How do I capture input from the customer and reuse it in a conversation?

Conversation Variables toggle

In this guide, we will walk you through the process of capturing and reusing user input within a conversation, using the example of a 5-digit zip code. By using a Regular Expression (regex) entity, we’ll show you how to capture the zip code entered by the user, store it in a Conversation Variable, and then reuse it throughout your interactions. This method allows for dynamic and personalized responses based on user input, improving the overall conversational experience. Let’s get started!

example conversation.png

Step 1: Create a Regular Expression Entity (Regex)

  1. Create a new 'expression' entity: This entity will recognize specific patterns in user input. In this case, you'll use it to capture numbers.
  2. Define the regex pattern: For example, if you want to capture 5-digit numbers, use a regex pattern that matches this format.Example:
    • Regex for capturing 5-digit numbers: \d{5}(-\d{4})?
  3. This will match any sequence of exactly five digits.

regex.png

Step 2: Link the Entity to a Conversation Variable

  1. Create a Conversation Variable: This variable will store the value captured by the regex entity.
  2. Link the Regular Expression entity to the Conversation Variable: This ensures that when the user provides input, the regex entity extracts the number and saves it in the variable.

link entity.png

Step 3: Create an Article to Capture the Input

  1. Create a new article: This article will be used to capture and respond to the user input.
  2. Add a question that will trigger the regex: 12345
  3. Add the Conversation Variable to the Answer: In the response, include the conversation variable to dynamically repeat the captured number back to the user. Example:
    • "You entered the number: {{conversation.variable}}"

article a.png

article b.png

Step 4: Use the Conversation Variable in Other Articles or Dialogs

  1. Reusing the Variable: You can now use the Conversation Variable wherever you need to repeat the captured value across multiple articles, dialog nodes, or event answers. Example:

article c.png

Additional Considerations

Handling Special Characters: If the number input includes characters like dashes or spaces (e.g., 123-456 or 123 456), the system may strip out these symbols, possibly resulting in an unintentional input format (e.g., 123456). Test your regex pattern to ensure it captures the number correctly in these cases.

Related Articles

group icon
Get support

Can’t find the answer you are looking for?
Ask for the help of our chatbot, or get in touch with our support team.

Contact Support
Is this region a better fit for you?
Go
close icon