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

编程入门 行业动态 更新时间:2024-10-09 22:16:55

带有λ的lex aws上的<a href=https://www.elefans.com/category/jswz/34/1771438.html style=自定义有效负载"/>

带有λ的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上的自定义有效负载

本文发布于:2024-05-07 11:10:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1755969.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   负载   lex   aws

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!