Botium Box reading javascript variables into convo files

Hello,

  1. I followed this documentation and added a botium capability to read javascript on my chatbot settings.
  2. I enabled scripting memory settings on my test set where I want to read a javascript variable but my bot gives undefined as a response.
  3. This works with inbuit variables like $now, $year

Apart from the example mentioned in the documentation above, this is something I tried.
On my chatbot under advanced settings and inside CUSTOMHOOK_ONBUILD capability I have this

  var test='Hi, I am coming from JS Capability'

In my test set, I enabled scripting memory and this is my convo.txt

Greet the bot
#me
chatid $cap(test)
#bot
$test

My expected output is
chatid Hi, I am coming from JS Capability
followed by bot response
but I get this
chatid undefined

Try it with this:

container.caps.test = 'Hi, I am coming from JS Capability'

or this:

module.exports = async ({ container }) => {
  container.caps.test = 'Hi, I am coming from JS Capability'
}

First one works, second one still gives undefined as a response.

1 Like

second one depends on the Botium version

I see I am on Botium Box 2.8.3, is there an alternative way to try this if it is not supported on this version?

Good point - the second thing is only available with the upcoming Botium Box release 2.8.8, has been added to Botium Core recently.
Haven’t tried it to be honest, but this one should also work right now:

module.exports = new Promise((resolve, reject) => {
  container.caps.test = 'Hi, I am coming from JS Capability'
  resolve()
})

This doesn’t work either. So to get api tokens botium box uses modules and I don’t see any other dependency apart from npm version. Where do I see which version of npm supports botium box 2.8.3? I will check if there is any other way to pass this token…

why not upgrade botium box ?

Yep thats an option but the latest version of Botium Box is 2.8.7 from your release docs and 2.8.8 is not yet released. Isn’t it? When is 2.8.8 out?

Planned for first week of may