### Install Botium CLI Globally Source: https://github.com/codeforequity-at/botium-core/wiki/DialogFlow-Testing-Tutorial Installs the Botium command-line interface globally. If you encounter errors, try installing windows-build-tools, Python 2, or running the command prompt as an administrator. ```bash npm install -g botium-cli ``` -------------------------------- ### Start Botium Script Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/connectors/simplerest-polling/Readme.md Execute this command to initiate the Botium script, which sends input to the bot and waits for responses. ```bash node botiumFluent.js ``` -------------------------------- ### Using Asserter in Conversation - Setup and Teardown Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/extensions/asserterHooks/README.md Demonstrates using a custom asserter ('DUMMY') with arguments for setup (inserting data) before a conversation and teardown (deleting data) after the conversation. Arguments are pipe-separated. ```botium-script restaurant #begin DUMMY dbUrl | dbPassword | INSERT INTO dummy(name, birthday) VALUES ('Max Mustermann', 1991-03-26); #me hi #bot Hi. It looks like a nice drive today. What would you like me to do? #me where is the next restauran #bot I understand you want me to find a location. I can find restaurants, gas stations and restrooms nearby. #me find my a restaurant #bot Of course. Do you have a specific cuisine in mind? #me pizza #bot Super! I've found 5 locations for you. Which one would you like to drive to? DUMMY arg1 | arg2 #me 1 #bot Sure! Restaurant 1 on the list gets great reviews. #bot What day/time did you want to go to the restaurant? #me 10th of january #bot OK #end DUMMY dbUrl | dbPassword | DELETE FROM dummy WHERE name='Max Mustermann'; ``` -------------------------------- ### Install Mochawesome for Test Reporting Source: https://github.com/codeforequity-at/botium-core/wiki/DialogFlow-Testing-Tutorial Installs Mochawesome globally, a tool used for generating test reports. This is typically done after setting up Botium. ```bash npm install -g mochawesome ``` -------------------------------- ### Start Chatbot Endpoint Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/connectors/simplerest-async/Readme.md Launches the chatbot endpoint for demonstration purposes. This script responds with random jokes and posts an additional asynchronous message. ```javascript node jokebot.js ``` -------------------------------- ### Start Botium Script with Integrated Endpoint Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/connectors/simplerest-async/Readme.md Starts the Botium script using an integrated HTTP inbound endpoint. This configuration sends input to the bot and waits for both synchronous and asynchronous responses. ```javascript BOTIUM_CONFIG=botium-inbound.json node botiumFluent.js ``` -------------------------------- ### Configure Asserter from Function Reference Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/extensions/asserterHooks/README.md Configuration example for adding a custom asserter using a function reference. The 'src' property contains the function definition to dynamically provide the asserter. ```json { "botium": { "Capabilities": { "PROJECTNAME": "Botium Scripting Sample", "CONTAINERMODE": "watson", "WATSON_USER": "0274cb6f-3680-4cf7-bd6b-71c7f447542d", "WATSON_PASSWORD": "ZWDE5xo02sby", "WATSON_WORKSPACE_ID": "97513bc0-c581-4bec-ac9f-ea6a8ec308a9", "ASSERTERS": [ { "ref": "DUMMY", "src": function() {...} } ] } } } ``` -------------------------------- ### Start Botium Script with Redis Endpoint Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/connectors/simplerest-async/Readme.md Starts the Botium script configured to use a Redis-based inbound endpoint. This requires the Botium CLI inbound proxy to be running and the chatbot connected to it. ```javascript BOTIUM_CONFIG=botium-redis.json node botiumFluent.js ``` -------------------------------- ### Configure Asserter from npm Package Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/extensions/asserterHooks/README.md Configuration example for adding a custom asserter by referencing a public npm package. The 'ref' is used to invoke the asserter, and 'src' points to the package name. ```json { "botium": { "Capabilities": { "PROJECTNAME": "Botium Scripting Sample", "CONTAINERMODE": "watson", "WATSON_USER": "0274cb6f-3680-4cf7-bd6b-71c7f447542d", "WATSON_PASSWORD": "ZWDE5xo02sby", "WATSON_WORKSPACE_ID": "97513bc0-c581-4bec-ac9f-ea6a8ec308a9", "ASSERTERS": [ { "ref": "DUMMY", "src": "custom-botium-asserter" } ] } } } ``` -------------------------------- ### Configure Asserter from Local File Path Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/extensions/asserterHooks/README.md Configuration example for adding a custom asserter by referencing a local file path. The 'src' property specifies the relative or absolute path to the asserter file. ```json { "botium": { "Capabilities": { "PROJECTNAME": "Botium Scripting Sample", "CONTAINERMODE": "watson", "WATSON_USER": "0274cb6f-3680-4cf7-bd6b-71c7f447542d", "WATSON_PASSWORD": "ZWDE5xo02sby", "WATSON_WORKSPACE_ID": "97513bc0-c581-4bec-ac9f-ea6a8ec308a9", "ASSERTERS": [ { "ref": "DUMMY", "src": "../../../samples/asserterHooks/DummyAsserter.js" } ] } } } ``` -------------------------------- ### Start Botium CLI Inbound Proxy Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/connectors/simplerest-async/Readme.md Launches the inbound endpoint using Botium CLI, which connects to a shared Redis topic. Ensure a local Redis server is running before executing this command. ```bash botium-cli inbound-proxy ``` -------------------------------- ### Scripting Memory Overwritten by Begin Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/logichooks/convos/scripting_memory_overwritten_by_begin.convo.txt Use the #begin directive to overwrite script memory variables previously set globally. This is useful for resetting or changing variable states at the start of a conversation flow. ```botium-scripting #begin SET_SCRIPTING_MEMORY created_by_global|created_by_global_from_begin ``` -------------------------------- ### Import Dialogflow Conversations Source: https://github.com/codeforequity-at/botium-core/wiki/DialogFlow-Testing-Tutorial Imports conversations from Dialogflow to create Botium test files (.convos.txt, _input.txt, _output_0.txt). Execute this command from a clean folder where you want the test files to be generated. ```bash botium-cli import dialogflow-conversations ``` -------------------------------- ### Passing Scripting Memory to Asserter Arguments Source: https://github.com/codeforequity-at/botium-core/blob/master/test/convo/convos/applyscriptingmemorytoasserterargs.convo.txt Demonstrates how to use scripting memory variables ($arg0, $arg1) as arguments for a custom asserter. This is useful for dynamic assertion values based on conversation context. ```botium-scripting #me question1 #bot $arg0 #me question2 #bot $arg1 CUSTOMASSERTER $arg0|$arg1 ``` -------------------------------- ### Using Scripting Memory Variables in Bot Responses Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/scriptingmemory/scriptingVariablesSeveralEntries/buy.convo.txt Reference scripting memory variables in bot responses using the '$' prefix. The variable's value will be substituted into the message. ```BotiumScript #me What would you like to eat? #bot I'd like to have a $productName and one more $productName ``` -------------------------------- ### Use Scripting Memory in Botium Script Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/logichooks/convos/scripting_memory_progress.convo.txt Reference stored scripting memory values using the '$' prefix in Botium script. This allows dynamic message content. ```convo #me sending input: $input ``` ```convo #bot sending input: $input ``` -------------------------------- ### Use Scripting Memory in Bot Response Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/logichooks/convos/scripting_memory_resolved_args.convo.txt Reference a scripting memory variable using the $ prefix in bot responses. This allows for dynamic content generation. ```botium-scripting TEXT_CONTAINS_ANY $myword ``` -------------------------------- ### Setting a Scripting Memory Variable Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/scriptingmemory/scriptingVariablesSeveralEntries/buy.convo.txt Use the SET_SCRIPTING_MEMORY command to assign a value to a variable. This variable can then be referenced in subsequent messages. ```BotiumScript SET_SCRIPTING_MEMORY productName|Schnitzel ``` -------------------------------- ### Convo Script with Non-existent Variable Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/scriptingmemory/convosNoIntersection/buy.convo.txt This convo script demonstrates a scenario where the '#me' input references a variable '$notInScriptingMemory' which is not defined in the scripting memory. Botium should handle this gracefully without multiplying the conversation. ```botium #begin #me $notInScriptingMemory #bot ``` -------------------------------- ### Automated Variant Generation Script Source: https://github.com/codeforequity-at/botium-core/wiki/DialogFlow-Testing-Tutorial This script utilizes an API (api.bitext.com) to automatically generate variations of input files for testing. Ensure you have signed up for an API trial and replaced the placeholder User Token. Place this script in the same directory as your .convos files. ```python import requests import json # Replace with your actual User Token from api.bitext.com USER_TOKEN = "YOUR_BITEXT_USER_TOKEN" API_URL = "https://api.bitext.com/v1/variants" def generate_variants(input_text): headers = { "Authorization": f"Token {USER_TOKEN}", "Content-Type": "application/json" } payload = { "text": input_text, "limit": 5 # Number of variants to generate } try: response = requests.post(API_URL, headers=headers, json=payload) response.raise_for_status() # Raise an exception for bad status codes data = response.json() return [variant['text'] for variant in data.get('variants', [])] except requests.exceptions.RequestException as e: print(f"API request failed: {e}") return [] if __name__ == '__main__': # Example usage: # This part would typically involve reading your .convos.txt files, # extracting the #me lines, generating variants, and then writing # new _input.txt files or modifying existing ones. sample_input = "What is the weather like today?" print(f"Generating variants for: '{sample_input}'") variants = generate_variants(sample_input) if variants: print("Generated Variants:") for variant in variants: print(f"- {variant}") else: print("No variants generated or an error occurred.") # To integrate this into your workflow: # 1. Read your .convos.txt files. # 2. For each '#me:' line, extract the input text. # 3. Call generate_variants() with the extracted text. # 4. Create or update corresponding _input.txt files with the generated variants. # (Note: The original script description implies modification of input files, # so you'd need logic to handle file creation/overwriting.) ``` -------------------------------- ### Python Script for Generating Convos Files Source: https://github.com/codeforequity-at/botium-core/wiki/DialogFlow-Testing-Tutorial A Python script to generate Botium .convos.txt files from a .txt file containing a list of inputs (utterances). Place this script in a new directory and run it to create the test files. It does not generate input/output files. ```python import sys import os def generate_convos(input_file): with open(input_file, 'r') as f: utterances = f.readlines() for i, utterance in enumerate(utterances): utterance = utterance.strip() if not utterance: continue convo_filename = f'test_{i:03d}.convos.txt' with open(convo_filename, 'w') as f_convo: f_convo.write(f'# Test Case {i+1}\n') f_convo.write(f'#me: {utterance}\n') f_convo.write(f'#bot: ') if __name__ == '__main__': if len(sys.argv) != 2: print('Usage: python generate_convos.py ') sys.exit(1) input_filename = sys.argv[1] if not os.path.exists(input_filename): print(f'Error: Input file "{input_filename}" not found.') sys.exit(1) generate_convos(input_filename) print(f'Generated convos files from {input_filename}') ``` -------------------------------- ### Set Scripting Memory Source: https://github.com/codeforequity-at/botium-core/blob/master/test/scripting/logichooks/convos/scripting_memory_progress.convo.txt Use the SET_SCRIPTING_MEMORY command to store a value in memory. This value can be referenced later using a variable. ```convo SET_SCRIPTING_MEMORY input|INPUT1 ``` -------------------------------- ### Custom Asserter Class Source: https://github.com/codeforequity-at/botium-core/blob/master/samples/extensions/asserterHooks/README.md Defines a base class for custom asserters with methods for different conversation stages. Implement these methods to add custom assertion logic. ```javascript const utils = require('util') module.exports = class CustomAsserter { constructor (context, caps = {}) { this.context = context this.caps = caps } assertConvoBegin ({convo, container, args}) { return Promise.resolve() } assertConvoStep (convo, convoStep, args, botMsg) { return Promise.resolve() } assertConvoEnd ({convo, container, transcript, args}) { return Promise.resolve() } } ``` -------------------------------- ### Match JSON Key and Value Source: https://github.com/codeforequity-at/botium-core/blob/master/test/convo/convos/json-matching-key-and-value.convo.txt Use this to assert that a JSON object contains specific keys with exact values. This is useful for verifying API responses or message payloads. ```json #me { "text": "Success!", "falsytext": "", "number": 1, "falsynumber": 0, "floating": 1.0, "falsyfloat": 0.0, "isBoolean": true, "isNotBoolean": false, "fullArray": ["entryOne"], "halfArray": [""], "emptyArray": [], "containsNothing": null } #bot { "text": "Success!", "falsytext": "", "number": 1, "falsynumber": 0, "floating": 1.0, "falsyfloat": 0.0, "isBoolean": true, "isNotBoolean": false, "fullArray": ["entryOne"], "halfArray": [""], "emptyArray": [], "containsNothing": null } ``` -------------------------------- ### Access Scripting Memory Variable Source: https://github.com/codeforequity-at/botium-core/blob/master/test/convo/convos/applyscriptingmemoryinbegin.convo.txt Access a stored script memory variable using the $variable_name syntax. This allows dynamic responses based on previously stored data. ```botium-scripting #me access token: $access_token ``` -------------------------------- ### JSON Message Structure Source: https://github.com/codeforequity-at/botium-core/blob/master/test/compiler/convos/txt/convos_jsonmessage.convo.txt This is the standard JSON message format used by Botium Core. It includes session details, the message text, and an optional data object for custom payloads. ```json { "sessionId": "1234567890876543", "text": "Text message", "data": { "key": "value" } } ``` -------------------------------- ### Set Scripting Memory Variable Source: https://github.com/codeforequity-at/botium-core/blob/master/test/convo/convos/applyscriptingmemoryinbegin.convo.txt Use SET_SCRIPTING_MEMORY to store a value in a script memory variable. The value can be a literal or captured from the conversation. ```botium-scripting #begin SET_SCRIPTING_MEMORY access_token|$cap(MYTOKEN) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.