Integrate AWS Lex Chatbot with Angular 7

Recently, I’ve been working on integrating a chatbot with Angular version 7 as part of our latest project, Optimal Visualisation Engine (OVE). In this blog, I’ll run you through how to integrate an AWS Lex chatbot with your Angular application (I’ve assumed you’ve already created a cool chatbot using AWS Lex).

Getting started

Install Angular on your machine and initialise an Angular application if you haven’t already.
To Integrate Lex Chatbot install aws-sdk and types definition using npm. This provides JavaScript API for AWS services and gives you type definitions for node.

npm install aws-sdk -S
npm install --save-dev @types/node

Since the aws-sdk assumes global to be present and this is removed from angular 6+ add the following to your pollyfil.ts file

LexRuntime: Chatbot uses the runtime API to understand user utterances (voice or text). 2 commands are available in LexRunTime. PostContent and PostText. PostContect is used to send text or Voice. I am using PostText since I am using only text messages.
In ngOnInit method