Specifying Lambda hook functions - QnABot on AWS

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:

  1. From the content designer, choose Import from the tools menu ( ☰ ).

  2. Select Examples/Extensions, and then choose LOAD from the GreetingHook example.

  3. 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.

  4. 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’.

    Example Lambda hook function.

    Example Lambda hook function

  5. Inspect the example function (ExampleJSLambdahook) using the AWS Lambda console.

  6. 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, refer to Extensions README in the QnABot on AWS GitHub repository.