AWS Lex-自定义有效载荷

时间:2020-04-28 12:07:15

标签: amazon-lex aws-lex

我正在尝试向用户发送带有复选框的表单,以使用户能够选择两个值中的最大值。在这种情况下,我试图从用户那里计算出他们最常见的两种运输方式是什么。您能建议如何做吗?

当前代码

  if (slots.TransportMode === null) {
      console.log('transport mode slot');

      let slotToElicit = 'TransportMode';
      let message = {
        contentType: "CustomPayload",
        content: "<div class='transport-mode'><p><strong>What are the 2 most common transport modes that you use?</strong></p><input class='single-checkbox' type='checkbox' name='Motorbike' value='Motorbike'>Motorbike<br><input class='single-checkbox' type='checkbox' name='Car' value='Car'>Car<br><input class='single-checkbox' type='checkbox' name='Bus' value='Bus'>Bus<br><input class='single-checkbox' type='checkbox' name='Train' value='Train'>Train<br></div>"
      };

      callback(lexResponses.ElicitSlot(intentRequest.sessionAttributes, intentRequest.currentIntent.name, slots, slotToElicit, message));
      return;

    }

引发插槽功能

module.exports.ElicitSlot = function(sessionAttributes, intentName, slots, slotToElicit, message) {
  return {
    sessionAttributes,
    dialogAction: {
      type: 'ElicitSlot',
      intentName,
      slots,
      slotToElicit,
      message,
    },
  };
}

0 个答案:

没有答案