Specifying Lambda hook functions
The solution’s content designer allows you to dynamically generate answers by specifying your own Lambda hook function for any item. When you specify the name, or ARN, of a Lambda function in the Lambda hook field for an item, QnABot on AWS will call your function any time that item is matched to an end user’s question. Your Lambda function can run code to integrate with other services, perform actions, and generate dynamic answers.
QnABot on AWS comes with a simple Lambda hook function example that you can customize:
-
From the content designer, choose Import from the tools menu (☰).
-
Select Examples/Extensions, and then choose LOAD from the GreetingHook example.
-
After the import job has completed, return to the edit page, and examine the item GreetingHookExample. The Lambda hook field is populated with a Lambda function name.
-
Use the web UI to say, “What are Lambda hooks?”. Note that the answer is prepended with a dynamic greeting based on the current time of day – in this case ‘good afternoon’.
-
Inspect the
ExampleJSLambdahook
Lambda function using the AWS Lambda console. -
Choose Lambda Hooks from the content designer tools menu (☰) to display additional information to help you create your own Lambda hook functions.
For more information about how you can package Lambda hooks, see
the
Extending
QnABot with Lambda hook functions