Skip to main content

CSV

CSV files play a crucial role in Botium for reading conversations, partial conversations, and utterances. This guide will help you understand the structures and capabilities of CSV files within Botium

CSV File Structure

Botium supports multiple structures for CSV files, though it's recommended to stick with the default structures for simplicity. The key features of CSV file handling in Botium include:

  • The first row is the header row (it will be skipped during processing).
  • The column delimiter is auto-detected (comma, tab, etc.) but can be fixed if needed.
  • The structure is recognized by the number of columns.

3 Columns: Multi-Turn Conversations

For multi-turn conversations, CSV files require three columns:

  1. conversationId: Groups conversations together (can be any unique identifier, such as a test case name).
  2. sender: Indicates who is sending the message ("me" for the user, "bot" for the bot).
  3. text: The message content.

Example

conversationId,sender,text
Greet the Bot,me,hello
Greet the Bot,bot,hello
second,me,how are you?
second,bot,I'm good, thanks!

2 Columns: 1-Turn Conversations (Question/Answer)

For single-turn question/answer conversations, CSV files require two columns:

  1. question: Contains the question from the user.
  2. answer: Contains the expected answer from the bot.

Example

question,answer
hello,Hi!
how are you?,I'm good, thanks!

1 Column: Utterances List

For listing utterances, a single column is used. The first line is the header, followed by the utterances.

Example

UTT_NAME
hello
Hi!
how are you?

CSV Parsing Capabilities

Botium provides several configuration options for parsing CSV files:

Default Settings

  • Delimiter: Auto-detected but can be fixed with SCRIPTING_CSV_DELIMITER.
  • Quote Character: Default is " but can be customized with SCRIPTING_CSV_QUOTE.
  • Escape Character: Default is " but can be set with SCRIPTING_CSV_ESCAPE.
  • Skip Header: By default, Botium expects a header line (SCRIPTING_CSV_SKIP_HEADER).

Column Selectors

By default, columns are processed in the order specified above. However, if you have a different column order, you can specify columns using the header name (if present) or the column index (starting from 0):

  • SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID
  • SCRIPTING_CSV_MULTIROW_COLUMN_SENDER
  • SCRIPTING_CSV_MULTIROW_COLUMN_TEXT
  • SCRIPTING_CSV_QA_COLUMN_QUESTION
  • SCRIPTING_CSV_QA_COLUMN_ANSWER

Example Configuration in Code

Here’s an example of how you might configure Botium to read a CSV file with different delimiters and custom column orders:

{
  "SCRIPTING_CSV_DELIMITER": ",",
  "SCRIPTING_CSV_QUOTE": "\"",
  "SCRIPTING_CSV_ESCAPE": "\"",
  "SCRIPTING_CSV_SKIP_HEADER": true,
  "SCRIPTING_CSV_MULTIROW_COLUMN_CONVERSATION_ID": "test_case_id",
  "SCRIPTING_CSV_MULTIROW_COLUMN_SENDER": 1,
  "SCRIPTING_CSV_MULTIROW_COLUMN_TEXT": 2
}

This JSON snippet configures Botium to:

  • Use a comma as the delimiter.
  • Use double quotes for quoting.
  • Skip the header row.
  • Use a custom column name for conversation IDs and specific column indices for sender and text.

By understanding and utilizing these structures and capabilities, you can effectively manage and customize how Botium processes your CSV files for testing and conversation handling.

Practical Tips

  1. Ensure Consistent Headers: For Botium to correctly parse the CSV files, make sure the headers match the expected structure.
  2. Handle Different Delimiters: Botium can auto-detect delimiters, but specifying them can avoid issues with complex data.
  3. Use Wildcards and Scripting Memory: For more flexible and reusable test cases, utilize wildcards and scripting memory to handle dynamic content.

Was this article helpful?

0 out of 0 found this helpful