带有lambda的Amazon lex AWS上的自定义有效负载

时间:2019-05-16 11:16:06

标签: node.js amazon-web-services aws-lambda amazon-lex

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

这是我到目前为止所拥有的:

'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': `https://meed.audiencevideo.com/videos/glad_hear.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);
    }
};

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

0 个答案:

没有答案