是的,AWS Lambda可以触发Power Automate Flow。下面是一个使用AWS Lambda和Node.js的示例代码:
const AWS = require('aws-sdk');
const lambda = new AWS.Lambda();
exports.handler = async (event, context) => {
// 构建Power Automate Flow所需的输入数据
const flowInput = {
// 输入参数1
param1: 'Value 1',
// 输入参数2
param2: 'Value 2',
// ...
};
// 构建Lambda调用Power Automate Flow的参数
const lambdaParams = {
FunctionName: 'YourPowerAutomateFlowFunctionName',
InvocationType: 'Event', // 异步调用
Payload: JSON.stringify(flowInput)
};
try {
// 调用Lambda函数触发Power Automate Flow
await lambda.invoke(lambdaParams).promise();
console.log('Power Automate Flow triggered successfully.');
return 'Success';
} catch (error) {
console.error('Failed to trigger Power Automate Flow:', error);
throw error;
}
};
在上面的代码中,我们使用AWS SDK for JavaScript来创建一个Lambda函数。在Lambda函数的handler
方法中,我们构建了Power Automate Flow所需的输入数据,并使用lambda.invoke
方法来触发Power Automate Flow。FunctionName
参数应为你的Power Automate Flow函数的名称,InvocationType
参数设置为Event
表示异步调用,Payload
参数是Power Automate Flow的输入数据。
请确保已正确配置AWS SDK和Power Automate Flow的访问权限。