带有自定义有效负载的Botium-DefaultWelcome:机器人说未定义

时间:2019-03-21 06:53:09

标签: testing dialogflow chatbot

我正在尝试使用botium测试我的应用程序。我已经使用botium-cli import dialogflow-conversations

生成了convo文件

我的DefaultWelcome意图低于有效载荷

{
  "cutomPayload": {
    "card": {
      "description": "Hey there! I’m a bot that can help you troubleshoot issues with UPS. Please enter the model number"
    }
  }
}

和以下培训阶段

just going to say hi
heya
hello hi
howdy
hey there
hi there
greetings
hey
long time no see
hello
lovely day isn't it
I greet you
hello again
hi
hello there
a good day

在我的convo文件夹中,我有DefaultWelcome.convo.txt和DefaultWelcome_input.utterances.txt

DefaultWelcome.convo.txt具有

DefaultWelcome

#me
DefaultWelcome_input

#bot
!INCOMPREHENSION

DefaultWelcome_input.utterances.txt具有

DefaultWelcome_input
just going to say hi
heya
hello hi
howdy
hey there
hi there
greetings
hey
long time no see
hello
lovely day isn't it
I greet you
hello again
hi
hello there
a good day

我试图运行

const BotDriver = require('botium-core').BotDriver;

const driver = new BotDriver();

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

但是不幸的是我得到了以下输出

botium-connector-dialogflow Start called +256ms
  botium-ScriptingProvider Using utterances expansion mode: all +172ms
  botium-Convo DefaultWelcome/Line 6: user says ConvoStep {
  botium-Convo   sender: 'me',
  botium-Convo   channel: null,
  botium-Convo   messageText: 'just going to say hi',
  botium-Convo   sourceData: undefined,
  botium-Convo   stepTag: 'Line 6',
  botium-Convo   not: false } +0ms
  botium-connector-dialogflow UserSays called +175ms
  botium-connector-dialogflow dialogflow request: {
  botium-connector-dialogflow   "session": "projects/joules-test/agent/sessions/defee8a0-4b08-11e9-93e7-fd1394066413",
  botium-connector-dialogflow   "queryInput": {
  botium-connector-dialogflow     "text": {
  botium-connector-dialogflow       "text": "just going to say hi",
  botium-connector-dialogflow       "languageCode": "en-US"
  botium-connector-dialogflow     }
  botium-connector-dialogflow   },
  botium-connector-dialogflow   "queryParams": null
  botium-connector-dialogflow } +0ms
  botium-connector-dialogflow dialogflow response: {
  botium-connector-dialogflow   "responseId": "27545943-441c-487f-9f45-2cd32e833ace",
  botium-connector-dialogflow   "queryResult": {
  botium-connector-dialogflow     "fulfillmentMessages": [
  botium-connector-dialogflow       {
  botium-connector-dialogflow         "platform": "PLATFORM_UNSPECIFIED",
  botium-connector-dialogflow         "payload": {
  botium-connector-dialogflow           "fields": {
  botium-connector-dialogflow             "cutomPayload": {
  botium-connector-dialogflow               "structValue": {
  botium-connector-dialogflow                 "fields": {
  botium-connector-dialogflow                   "card": {
  botium-connector-dialogflow                     "structValue": {
  botium-connector-dialogflow                       "fields": {
  botium-connector-dialogflow                         "description": {
  botium-connector-dialogflow                           "stringValue": "Hey there! I’m a bot that can help you troubleshoot issues with Back-UPS. Please enter your model number",
  botium-connector-dialogflow                           "kind": "stringValue"
  botium-connector-dialogflow                         }
  botium-connector-dialogflow                       }
  botium-connector-dialogflow                     },
  botium-connector-dialogflow                     "kind": "structValue"
  botium-connector-dialogflow                   }
  botium-connector-dialogflow                 }
  botium-connector-dialogflow               },
  botium-connector-dialogflow               "kind": "structValue"
  botium-connector-dialogflow             }
  botium-connector-dialogflow           }
  botium-connector-dialogflow         },
  botium-connector-dialogflow         "message": "payload"
  botium-connector-dialogflow       }

  botium-Convo DefaultWelcome wait for bot null +3s
  botium-BaseContainer WaitBotSays error Error: Queue.pop timeout after 60000
  botium-BaseContainer     at timeoutRequest (/Users/madhavam/joules-botium/node_modules/botium-core/src/helpers/Queue.js:46:18)
  botium-BaseContainer     at Timeout.timeoutCallback [as _onTimeout] (/Users/madhavam/joules-botium/node_modules/async/dist/async.js:4936:13)
  botium-BaseContainer     at ontimeout (timers.js:427:11)
  botium-BaseContainer     at tryOnTimeout (timers.js:289:5)
  botium-BaseContainer     at listOnTimeout (timers.js:252:5)
  botium-BaseContainer     at Timer.processTimers (timers.js:212:10) +0ms
  botium-Convo DefaultWelcome: bot says undefined +1m
ERROR:  Error: DefaultWelcome/Line 8: bot says nothing
    at Object.fail (/Users/mma/joules-botium/node_modules/botium-core/src/scripting/ScriptingProvider.js:50:15)
    at container.WaitBotSays.then (/Users/madhavam/joules-botium/node_modules/botium-core/src/scripting/Convo.js:64:49)

那么如何解决这个问题?无论如何,我是否能够处理特定的响应?

1 个答案:

答案 0 :(得分:1)

不支持自定义有效负载是Botium Dialogflow连接器的当前限制之一,请参阅:https://github.com/codeforequity-at/botium-connector-dialogflow#open-issues-and-restrictions

使用Botium CLI时,您无需编写任何Botium代码-您可以使用cli运行测试用例:

> botium-cli run --convos ./convos

更新

您可以将功能_DIALOGFLOW_FORCE_INTENT_RESOLUTION_设置为true,以在连接器无法识别任何已知内容时甚至向Botium做出响应。然后,您就一站式了。

要实际声明响应,可以使用集成的JSON结构匹配,但是由于Dialogflow自定义有效负载结构的性质,您的convo文件将变得很混乱。

您的convo文件应如下所示

DefaultWelcome

#me
DefaultWelcome_input

#bot
{  
   "fulfillmentMessages":[  
      {  
         "platform":"PLATFORM_UNSPECIFIED",
         "payload":{  
            "fields":{  
               "cutomPayload":{  
                  "structValue":{  
                     "fields":{  
                        "card":{  
                           "structValue":{  
                              "fields":{  
                                 "description":{  
                                    "stringValue":"Hey there! I’m a bot that can help you troubleshoot issues with Back-UPS. Please enter your model number",
                                 }
                              }
                           },
                        }
                     }
                  },
               }
            }
         },
      }
   ]
}