Closed github1 closed 6 years ago
I would argue that the lambda function does not need an environment variable for callbacks to the platform (unless we are doing the validation on the platform) because once a ChatReadyForFulfilment
event is dispatched all slots should have been validated and we have the slot values in the platform already.
Yes, we technically don't need it for simple validations. That said, I think we'll need the lambda function/dialog code hook to add support for authentication.
Ye thats a good point. That URL will be the one exposed by Ngrok right?
It could be ngrok or the actual public url the service is exposed from.
Have you tried to upload a lambda function via a zipfile before? I'm having real trouble getting it to be able to read my file...
I tried using the aws-cli, you can specify a path to a zip file but you need to prefix it with fileb://
, as in fileb://file-path/file.zip
. Maybe give that a shot.
Ye I've seen there is lots of information available on doing it via the CLI, but not a lot for the SDK. I've tried passing the path in a similar way to { Code: ZipFile : 'PATH' ... }
but that doesn't seem to be working for me. I keep getting "could not upload file" error
I was able to get to work this way - essentially the zip content has to be passed in as a Buffer:
const AWS = require('aws-sdk');
const fs = require('fs');
// AWS.config.update ...
fs.readFile('/path/to/lambda-function.zip', (err, data) => {
var params = {
FunctionName: "test",
ZipFile: data
};
lambda.updateFunctionCode(params, function (err, data) {
if (err) console.log(err, err.stack);
else console.log(data);
});
});
just pushed this to the branch lambda-builder, its not quite ready to merge as there is one thing that needs to be fixed with this section of the bot_builder:
}).then(() => {
console.log('Published');
Object.keys(lexmodel).map((type) => {
Object.keys(lexmodel[type]).map((key) => {
console.log(` ${type} ${key} v${lexmodel[type][key].version}`);
});
});
}).then(() => {
console.log('lexmodel is:');
console.log(lexmodel);
}).catch(err => {
console.error(err);
});
its giving the following error:
role Path vundefined
role RoleName vundefined
role RoleId vundefined
role Arn vundefined
role CreateDate vundefined
role AssumeRolePolicyDocument vundefined
role Description vundefined
lambdaFunction FunctionName vundefined
lambdaFunction FunctionArn vundefined
lambdaFunction Runtime vundefined
lambdaFunction Role vundefined
lambdaFunction Handler vundefined
lambdaFunction CodeSize vundefined
lambdaFunction Description vundefined
lambdaFunction Timeout vundefined
lambdaFunction MemorySize vundefined
lambdaFunction LastModified vundefined
lambdaFunction CodeSha256 vundefined
lambdaFunction Version vundefined
TypeError: Cannot read property 'version' of null
at Object.keys.map (/Users/GraemeCottrell/Dev/ccnext/platform/src/bot/bot_builder.js:90:59)
at Array.map (native)
at Object.keys.map (/Users/GraemeCottrell/Dev/ccnext/platform/src/bot/bot_builder.js:89:33)
at Array.map (native)
I haven't even looked at what the problem is, probably a quick fix but just wanted to get this up and go to sleep!
@github1 so this is done now, except from one last thing:
if you look at the bot configurator in the branch lambda-builder
the policy of the lambda function is updated to include each intent by extracting the name of the intents from the lexmodel.
So the intents need to have been created/updated before updating the policy. But if we want the intents to include the lambda function as the dialog code hook, the policy needs to have been updated already otherwise we get an error.
So each needs the other to have happened first. I couldn't think of an elegant solution to solve this, wondered if you had any ideas?
closed via ee353bcf8221d60820dffff88e088d4a5be2bf9d
As part of the lex bot configuration process, a lambda function should be deployed and attached as a codehook on the bot.