admin管理员组

文章数量:815041

带有λ的lex aws上的自定义有效负载

我有一个简单的机器人来订购披萨,具有完整功能,我想显示视频而不是消息。

这是我到目前为止的内容:

'use strict';

// Close dialog with the customer, reporting fulfillmentState of Failed or Fulfilled ("Thanks, your pizza will arrive in 20 minutes")
function close(sessionAttributes, fulfillmentState, message) {
    return {
        sessionAttributes,
        dialogAction: {
            type: 'Close',
            fulfillmentState,
            message,
        },
    };
}

// --------------- Events -----------------------

function dispatch(intentRequest, callback) {
    console.log(`request received for userId=${intentRequest.userId}, intentName=${intentRequest.currentIntent.name}`);
    const sessionAttributes = intentRequest.sessionAttributes;
    const slots = intentRequest.currentIntent.slots;
    const crust = slots.crust;
    const size = slots.size;
    const pizzaKind = slots.pizzaKind;

    callback(close(sessionAttributes, 'Fulfilled',
    {
    'contentType': 'CustomPayload', 
    'content': `.mp4`}));

}

// --------------- Main handler -----------------------

// Route the incoming request based on intent.
// The JSON body of the request is provided in the event slot.
exports.handler = (event, context, callback) => {
    try {
        dispatch(event,
            (response) => {
                callback(null, response);
            });
    } catch (err) {
        callback(err);
    }
};

不幸的是,我的函数现在仅返回我一个链接。

回答如下:

您设法弄清楚了吗?关于自定义有效负载如何与自定义网络聊天一起工作的任何想法?找不到有关如何在不同频道上显示这些内容的资源。...在这种情况下,我希望用户能够从复选框中选择值。代码如下:

       let slotToElicit = 'TransportMode';
          let message = {
                contentType: "CustomPayload",
            content: `<div><input type="checkbox" id="vehicle1" name="vehicle1" value="Bike">
<label for="vehicle1"> I have a bike</label><br>
<input type="checkbox" id="vehicle2" name="vehicle2" value="Car">
<label for="vehicle2"> I have a car</label><br>
<input type="checkbox" id="vehicle3" name="vehicle3" value="Boat">
<label for="vehicle3"> I have a boat</label><br></div>`
          };

将感谢您的帮助!

本文标签: 带有λ的lex aws上的自定义有效负载