codeforequity-at / botium-bindings

The Selenium for Chatbots
http://www.botium.at
MIT License
108 stars 33 forks source link

unable to read utterances txt file with botium-bindings - ERROR: Error: No compiler for scriptFormat SCRIPTING_TYPE_UTTERANCESnd #116

Closed jpiduru closed 4 years ago

jpiduru commented 4 years ago

I am new user in the botium space and am trying to run the convo with an utterance file and getting error

FYI - i am using Alexa SMAPI connector

Here is the code

package.json has

"expandConvos": true, "expandUtterancesToConvos": false, "expandScriptingMemoryToConvos": false

//Reading convo file const scriptBuffer = fs.readFileSync(path.join(__dirname, 'convo/pin.convo.txt'))

//Reading utterance file const script = fs.readFileSync(path.join(__dirname, 'convo/cbal.utterances.txt'))

driver.BuildFluent() .Compile(scriptBuffer, 'SCRIPTING_FORMAT_TXT') // compiling convo file .Compile(script,'SCRIPTING_TYPE_UTTERANCES') // compiling utterance file .RunScripts() .Exec() .then(() => { console.log('SUCCESS :)') }) .catch((err) => { console.log('ERROR: ', err) })

ERROR: Error: No compiler found for scriptFormat SCRIPTING_TYPE_UTTERANCES at ScriptingProvider.GetCompiler (/Users/xxxxxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/ScriptingProvider.js:372:11) at ScriptingProvider.Compile (/Users/xxxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/ScriptingProvider.js:360:27) at Promise (/Users/xxxx/botiumWorkspace/node_modules/botium-core/src/Fluent.js:93:25) at new Promise () at Compile.tasks.push (/Users/xxxx/botiumWorkspace/node_modules/botium-core/src/Fluent.js:84:14) at async.eachSeries (/Users/xxx/botiumWorkspace/node_modules/botium-core/src/Fluent.js:30:30) at /Users/xxxxxxxx/botiumWorkspace/node_modules/async/dist/async.js:2158:44 at replenish (/Users/xxxxx/botiumWorkspace/node_modules/async/dist/async.js:444:21) at iterateeCallback (/Users/xxxx/botiumWorkspace/node_modules/async/dist/async.js:428:21) at /Users/xxxxxxx/botiumWorkspace/node_modules/async/dist/async.js:325:20 at taskResult.then (/Users/xxxxx/botiumWorkspace/node_modules/botium-core/src/Fluent.js:32:35) at process._tickCallback (internal/process/next_tick.js:68:7)

codeforequity-at commented 4 years ago

First let me point you to some info about the Botium Stack - using Botium Core directly, as you tried here, is usually not a good idea. There are frontend products available like Botium Bindings, Botium CLI and Botium Box.

Coming to your question: The second parameter for the Compile function is the file format, the 3rd parameter is the content type. In your case, this would be the correct call:

.Compile(script,'SCRIPTING_FORMAT_TXT','SCRIPTING_TYPE_UTTERANCES')
jpiduru commented 4 years ago

Thank you that worked!

Thanks for the botium stack details. I had several Intents and would like to separate the convo and utterances files per spec file and run the required intent tests.

i tried below code (assuming i am using botium bindings) but the utterances.txt file is not identified. Not sure how to call out utterence.txt in the below code.

utterance.txt file

USER_CBAL_UTT show my balance tell my balance check my balance what is my balance

driver.BuildFluent() .ReadScripts('./spec/convo/pin.convo.txt') .Start() .RunScripts() .Stop() .Clean() .Exec() .then(() => { console.log('READY') }) .catch((err) => { console.log('ERROR: ', err) })

=============== InlineHook onMeStart before sending text: USER_CBAL_UTT InlineHook onMeEnd after sending text: USER_CBAL_UTT InlineHook onBotStart expecting text: Your xxxxxxxx . What would you like to do next? ERROR: { TranscriptError: test case for pin/Line 27: Expected bot response (on Line 23: #me - USER_CBAL_UTT) “xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" at async.waterfall (/Users/xxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/Convo.js:227:25) at wrapper (/Users/xxxxx/botiumWorkspace/node_modules/async/dist/async.js:272:20) at next (/Users/xxxx/botiumWorkspace/node_modules/async/dist/async.js:4584:24) at /Users/xxxxxx/botiumWorkspace/node_modules/async/dist/async.js:325:20 at runConversation (/Users/xxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/Convo.js:205:15) at async.mapSeries (/Users/xxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/Convo.js:449:9) at err (/Users/xxxxxx/botiumWorkspace/node_modules/async/dist/async.js:252:13) at wrapper (/Users/xxxxxxx/botiumWorkspace/node_modules/async/dist/async.js:272:20) at iterateeCallback (/Users/xxxx/botiumWorkspace/node_modules/async/dist/async.js:417:21) at /Users/xxxxxxxx/botiumWorkspace/node_modules/async/dist/async.js:325:20 at _iteratee (/Users/xxxxxx/botiumWorkspace/node_modules/async/dist/async.js:249:17) at convoStepDone (/Users/xxxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/Convo.js:279:11) at scriptingEvents.onBotStart.then.then (/Users/xxxxxxx/botiumWorkspace/node_modules/botium-core/src/scripting/Convo.js:379:30) name: 'TranscriptError', transcript: Transcript { steps: [ [TranscriptStep], [TranscriptStep], [TranscriptStep], [TranscriptStep], [TranscriptStep], [TranscriptStep] ],

codeforequity-at commented 4 years ago

you can read whole directory with the ReadScripts function. You will have to tell Botium to do the utterances expansion afterwards, the settings in package.json are only used by Botium Bindings to do this automatically.

driver.BuildFluent()
.ReadScripts('./spec/convo/')
.Call(({ compiler}) => compiler.ExpandConvos())
.Start()
...

Again, I see no point in using Botium Core directly (except you want to learn and take part in Botium Core development ...)

jpiduru commented 4 years ago

Got it. Thanks for the details. Appreciate your help!