codeforequity-at / botium-core

The Selenium for Chatbots - Bots Testing Bots
https://www.botium.ai
MIT License
230 stars 64 forks source link

Running Scripts from a "convos" directory #60

Closed rafaelBergamin closed 6 years ago

rafaelBergamin commented 6 years ago

Hi, I'm trying to execute some scripted convo files in a directory, but it seems that is not beeing executed.

This is my botiumFluent.js

`const BotDriver = require('../../index').BotDriver const Capabilities = require('../../index').Capabilities const Source = require('../../index').Source

function assert (expected, actual) { if (!actual || actual.indexOf(expected) < 0) { console.log(ERROR: Expected <${expected}>, got <${actual}>) } else { console.log(SUCCESS: Got Expected <${expected}>) } }

const driver = new BotDriver() .setCapability(Capabilities.PROJECTNAME, 'Test') .setCapability(Capabilities.CONTAINERMODE, 'watsonconversation') .setCapability(Capabilities.WATSONCONVERSATION_USER, 'xxxx') .setCapability(Capabilities.WATSONCONVERSATION_PASSWORD, 'xxxx') .setCapability(Capabilities.WATSONCONVERSATION_WORKSPACE_ID, 'xxxx')
.setCapability(Capabilities.WATSONCONVERSATION_COPY_WORKSPACE, false)

driver.BuildFluent()

.ReadScripts('convos') .Start() .RunScripts() .Exec() .then(() => { console.log('READY') }) .catch((err) => { console.log('ERROR: ', err) })`

This is my convo file in the 'convos' directory:

`test

me

saldo credito

bot

sera diferente de uma cota para outra, mesmo sendo mesmo grupo, devido a taxas e processo de contemplacao

bot

Em que mais posso lhe ajudar ?

me

oi

bot

Eu nao entendi. Voce pode tentar reformular a frase.

me

ate mais

bot

Obrigado por utilizar o chat de consorcios `

When executing my node script with the command "node botiumFluent.js", it only logs "READY", but the scripts aren`t executed as well.

I'm attaching a screenshot showing my directory files.

Please, can you help me ? directory

codeforequity-at commented 6 years ago

Hi, everything looks fine with your configuration. Can you please enable debug logging ("export DEBUG=botium*") and attach the output here.

rafaelBergamin commented 6 years ago

Hi, thanks for the reply. I`m using the export debug command, and the temp dir in botiumwork is being created, but no sign of log files, i already put to windows show hidden files and nothing. Any hint ? sem titulo

codeforequity-at commented 6 years ago

Debug output is sent to the command line window, not written to log files. The botiumwork directory is just for temporary files (and it is an old bug that it doesn't get deleted in some cases).

So, in a command line window, this is what you should do:

> export DEBUG=botium* (in bash)
> set DEBUG=botium* (in windows cmd)
> node botiumFluent.js

By the way, if it logs "READY" to the command line window, it seems as if the conversations are actually executed.

If you are working with conversation scripts, I suggest to take a look at the botium-cli - no need to do Javascript coding when using the cli.

rafaelBergamin commented 6 years ago

Thank you, it really works!! By the way, using the debug command, I was able to see the error in my script:

`botium-cli-mocha-spec running testcase Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito +7ms botium-Convo Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito/Line 7: user says ConvoStep { botium-Convo sender: 'me', botium-Convo channel: null, botium-Convo messageText: '', botium-Convo sourceData: undefined, botium-Convo stepTag: 'Line 7', botium-Convo not: false } +14ms botium-WatsonConversationContainer Watson response: { intents: [], botium-WatsonConversationContainer entities: [], botium-WatsonConversationContainer input: { text: '' }, botium-WatsonConversationContainer output: botium-WatsonConversationContainer { text: [ 'Olá. Como posso te ajudar?' ], botium-WatsonConversationContainer nodes_visited: [ 'Bem-vindo' ], botium-WatsonConversationContainer log_messages: [] }, botium-WatsonConversationContainer context: botium-WatsonConversationContainer { conversation_id: '3464c4bb-28bb-47aa-a8f0-070644259ed4', botium-WatsonConversationContainer system: botium-WatsonConversationContainer { dialog_stack: [Array], botium-WatsonConversationContainer dialog_turn_counter: 1, botium-WatsonConversationContainer dialog_request_counter: 1, botium-WatsonConversationContainer _node_output_map: [Object], botium-WatsonConversationContainer branch_exited: true, botium-WatsonConversationContainer branch_exited_reason: 'completed' } } } +438ms botium-Convo Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito wait for bot null +431ms botium-Convo Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito: bot says BotiumMockMessage { botium-Convo sender: 'bot', botium-Convo channel: 'default', botium-Convo messageText: 'Olá. Como posso te ajudar?', botium-Convo sourceData: botium-Convo { intents: [], botium-Convo entities: [], botium-Convo input: { text: '' }, botium-Convo output: { text: [Array], nodes_visited: [Array], log_messages: [] }, botium-Convo context: botium-Convo { conversation_id: '3464c4bb-28bb-47aa-a8f0-070644259ed4', botium-Convo system: [Object] } }, botium-Convo sourceAction: undefined } +2ms botium-cli-mocha-spec Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito failed: Error: Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito/Line 10: Expected bot response "Olá. Como posso te ajudar?" to match one of "Ol?, sou seu assistente virtual e vou te ajudar com o d?vidas de cons?rcio. Como posso te ajudar ?" botium-cli-mocha-spec at Object.assertBotResponse (C:\Users\RAFAELBERGAMINDASILV\AppData\Roaming\npm\node_modules\botium-cli\node_modules\botium-core\dist\botium-cjs.js:1068:17) botium-cli-mocha-spec at C:\Users\RAFAELBERGAMINDASILV\AppData\Roaming\npm\node_modules\botium-cli\node_modules\botium-core\dist\botium-cjs.js:521:51 botium-cli-mocha-spec at botium-cli-mocha-spec at process._tickCallback (internal/process/next_tick.js:188:7) +440ms

1) Botium Test-Suite Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito: Error: Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito/Line 10: Expected bot response "Olá, sou seu assistente virtual e vou te ajudar com o dúvidas de consórcio. Como posso te ajudar ?" to match one of "Ol�, sou seu assistente virtual e vou te ajudar com o d�vidas de cons�rcio. Como posso te ajudar ?" at Object.assertBotResponse (C:\Users\RAFAELBERGAMINDASILV\AppData\Roaming\npm\node_modules\botium-cli\node_modules\botium-core\dist\botium-cjs.js:1068:17) at C:\Users\RAFAELBERGAMINDASILV\AppData\Roaming\npm\node_modules\botium-cli\node_modules\botium-core\dist\botium-cjs.js:521:51 at at process._tickCallback (internal/process/next_tick.js:188:7)`

My convo script is the following: `Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito

me

Mensagens_Inicio_input

bot

Olá, sou seu assistente virtual e vou te ajudar com o dúvidas de consórcio. Como posso te ajudar ?

me

Consorcio_CreditoEmEspecie_ConsultarCriterio_Credito_input

bot

Aguardando criação da resposta`

And my utterances is this:

Mensagens_Inicio_input Olá ola ola Oi oi tudo bem tudo bem? Tudo bem Tudo bem? Me ajude Preciso de ajuda td bem? bem?

There's some issue using accents ? Sorry for asking another problem.

Thanks in advance.

codeforequity-at commented 6 years ago

This really looks like some troubles with accents. Are the convo files UTF-8 encoded ?

rafaelBergamin commented 6 years ago

Hi, changed the convo files encoding and worked perfectly. Thank you for the support.