Skip to main content

Parameters

Parameters allow you to store and reference data throughout your bot's conversational flows, enabling personalized and dynamic interactions with users.

What are Parameters?

Parameters are key-value pairs that store information during a conversation. They act as variables that can hold user responses, system data, or any other information you need to reference throughout your bot's flow.

Setting Parameters

Using the Parameter Step

Parameters are set using the Parameter Step within story nodes. When you add a Parameter Step to a node, you define:

  • Key: The name of the parameter (e.g., user_name, email, preference)
  • Value: The data to store (can be static text, user input, or dynamic values)

Example:

Parameter Step:
├── Key: user_name
└── Value: John Doe

Parameter Namespaces

Session Namespace

All parameters you set via the Parameter Step are stored under the session namespace. These parameters:

  • Persist throughout the user's conversation session
  • Are isolated per user (each user has their own parameters)
  • Can be referenced in any part of your bot's flows

System Namespace

Botnex provides built-in parameters through the system namespace that are automatically updated:

system.last_utterance

  • Contains the exact text of whatever the user last input
  • Updates every time the user sends a message

system.last_intent

  • Contains the name of the last intent that was successfully matched
  • Updates whenever an intent is recognized from user input

Referencing Parameters

To reference parameters in your messages and content, use string interpolation with double curly braces:

{{ session.parameter_name }}
{{ system.parameter_name }}

Basic Examples

Personalizing messages:

Hello {{ session.user_name }}, welcome back!

Using system parameters:

You said: "{{ system.last_utterance }}"
I detected that you want to {{ system.last_intent }}.

Combining parameters:

Hi {{ session.user_name }}, you mentioned "{{ system.last_utterance }}" and I understood you want to {{ system.last_intent }}.

Common Use Cases

User Profile Management

Registration Flow:
├── Collect name → session.user_name
├── Collect email → session.email
└── Welcome message: "Hello {{ session.user_name }}!"

Multi-Step Forms

Booking Flow:
├── Select service → session.service_type
├── Choose date → session.appointment_date
└── Confirmation: "Your {{ session.service_type }} is booked for {{ session.appointment_date }}"

Conversation Context

Support Flow:
├── Store issue → session.issue_type
├── Response: "I'll help you with {{ session.issue_type }}"
└── Follow-up: "Is your {{ session.issue_type }} issue resolved?"

Managing Parameters

Clearing Parameters

To clear a parameter, set its value to empty in a Parameter Step:

Parameter Step:
├── Key: user_name
└── Value: [empty/blank]

Parameter Validation

Check if a parameter exists before using it:

{% if session.user_name %}
Hello {{ session.user_name }}!
{% else %}
Hello there!
{% endif %}

Best Practices

Naming Conventions

  • Use descriptive names: user_email instead of email
  • Follow consistent patterns: user_name, user_email, user_phone
  • Use snake_case: appointment_date instead of appointmentDate

Data Management

  • Initialize parameters with default values when needed
  • Clear parameters when no longer needed
  • Use meaningful parameter names for team collaboration

Security

  • Don't store sensitive data like passwords
  • Validate user input before storing
  • Only store what you need for the conversation

Troubleshooting

Common Issues

Parameter not found:

  • Ensure the Parameter Step executes before referencing the parameter
  • Check that the parameter key matches exactly
  • Verify you're using the correct namespace (session. or system.)

Incorrect syntax:

<!-- Wrong -->
{{ user_name }}

<!-- Correct -->
{{ session.user_name }}

By using parameters effectively, you can create personalized, context-aware conversations that adapt to user needs and maintain information throughout your bot's flows.