2017-05-31 24 views
0

我使用節點建設與botbuilder框架機器人,現在我想用CardAction.dialogAction:Botbuilder路由操作的消息來糾正對話框

builder.CardAction.dialogAction(session, 'help', 'topic:mytopic', 'Click me') 

它生成一條消息,如下所示:

action?help=topic:mytopic 

現在我需要將該行爲路由到正確的對話框來處理它,但我無法弄清楚在哪裏以及如何做到這一點。鑑於這是一個內置功能,我認爲應該有簡單的方法來做到這一點?

欣賞幫助。

+0

這是使用它的方式,但從v3.8開始,它似乎是一個錯誤,不再工作。 –

回答

0

對於缺乏任何其他選擇在這一點上,我訴諸寫我自己的簡單動作識別器。這不是美女,但它有訣竅。

function action_recognizer() { 
    return { 
    recognize: function (context, done) { 
     let intent = { score: 0.0 } 
     const text = context.message.text 
     if (text) { 
     const m = text.match(/action\?(\w+)=?(.+)/) 
     logger.debug(m) 
     if (m) { 
      switch (m[1]) { 
      case 'help': 
      intent = { score: 1.0, intent: 'help' } 
      if (m.length > 2) { 
       intent.entities = [{entity: m[2], type: 'custom_intent'}] 
      } 
      break 
      } 
     } 
     } 
     done(null, intent) 
    } 
    } 
} 

這將基本上直接指向我的help:/對話框。這又將讀取實體列表(如果custom_intent類型可用)。