Igor L.
Igor L.

Reputation: 3445

How to setup the botium.json for a simplerest service mode

I have a very simple "bot server" that responds to the presented utterance with the same utterance:

const express = require('express')
const app = express()

app.use(express.json())

const port = 3001

app.get('/', (req, res) => res.send('Hello World!'))

app.post('/message', (req, res) => {
    res.send({output: req.body.input})
  })

app.listen(port, () => console.log(`Example app listening on port ${port}!`))

Message flow:

me: POST -> http://localhost:3001/message -> { "input": "hi" }

bot: Responds with: { "output": "hi" }

botium.json:

{
    "botium": {
      "Capabilities": {
        "PROJECTNAME": "whatever",
        "CONTAINERMODE": "simplerest",
        "SIMPLEREST_URL": "http://localhost:3001/message",
        "SIMPLEREST_METHOD": "POST",
        "SIMPLEREST_BODY_TEMPLATE": "{\"text\": \"{{input}}\"}",
        "SIMPLEREST_RESPONSE_JSONPATH": "$.output",
        "SIMPLEREST_PING_URL": "http://localhost:3001/"
      },
      "Sources": {},
      "Envs": {
        "NODE_TLS_REJECT_UNAUTHORIZED": 0
      }
    }
  }

The emulator browser opens without problems, but the "bot" does not respond..

Upvotes: 0

Views: 162

Answers (1)

Igor L.
Igor L.

Reputation: 3445

I misunderstood the docs - body rest template should look like this:

"SIMPLEREST_BODY_TEMPLATE": "{\"input\": \"{{msg.messageText}}\"}",

Where "input" is a the path to the input utterance - by contract with your REST service

The "msg.messageText" is apparently used by botium to know how to access the utterance

Upvotes: 1

Related Questions