1
00:00:00,300 --> 00:00:07,560
In this video, we are going to understand how the circuit API is delivered to lambda function with

2
00:00:07,560 --> 00:00:08,980
the event object.

3
00:00:09,180 --> 00:00:14,660
And after that we will develop our lambda function with incoming event to perform business logics.

4
00:00:14,670 --> 00:00:20,220
So as you can see that we are in here, we have created Lambda Function and Circuit API and we have

5
00:00:20,220 --> 00:00:24,930
Circuit API, have different roles and this route is triggering our lambda function.

6
00:00:24,930 --> 00:00:28,170
So we will understand how different routes are.

7
00:00:28,170 --> 00:00:32,490
Typical lambda function from the circuit API to lambda function.

8
00:00:32,490 --> 00:00:34,080
So let's get started.

9
00:00:35,340 --> 00:00:40,330
In the last video we have connect the web socket API with the link of the API gateway.

10
00:00:40,350 --> 00:00:43,170
Please open the your web socket API.

11
00:00:43,200 --> 00:00:46,410
Go to stage and copy this web socket URL.

12
00:00:46,440 --> 00:00:49,600
This is our web socket connection URL.

13
00:00:49,650 --> 00:00:55,190
And after that, we are going to connect again with the socket test URL.

14
00:00:55,200 --> 00:01:01,260
So please paste in here and click the connect button when we click the connect button.

15
00:01:01,290 --> 00:01:03,840
This will be raw to the connect.

16
00:01:04,830 --> 00:01:06,570
Communication didn't show in here.

17
00:01:06,600 --> 00:01:13,950
This will be triggered this connect and invoked our lambda function and we will see how web socket API

18
00:01:14,070 --> 00:01:19,200
connect and invoke our lambda function from the connect root in this stage.

19
00:01:19,200 --> 00:01:26,430
So we will look at the logs into the Amazon Cloud log, but before that we should put the log statement

20
00:01:26,430 --> 00:01:27,690
in the lambda function.

21
00:01:27,690 --> 00:01:33,960
We forgot to log incoming event in lambda function because without these line of code, we didn't see

22
00:01:33,960 --> 00:01:36,210
incoming event from the web socket API.

23
00:01:36,210 --> 00:01:42,780
So before that, please go to the lambda function, open the lambda function, chat function, come

24
00:01:42,780 --> 00:01:47,160
to the code window and in the code window we are going to log incoming event.

25
00:01:47,160 --> 00:01:49,920
It is really important to understand incoming event.

26
00:01:49,920 --> 00:01:54,210
So please add this line of code and deploy the function.

27
00:01:55,800 --> 00:02:01,560
After we have deployment to function, we are ready to invoke to connect growth from the web socket

28
00:02:01,560 --> 00:02:04,110
API to our lambda function.

29
00:02:04,110 --> 00:02:11,550
Now we can connect to our web API and invoke to our connect route and see how lambda function is triggered.

30
00:02:11,790 --> 00:02:20,100
For that purpose, please open the web socket test page and paste the WASC URL and click the connect

31
00:02:20,100 --> 00:02:23,370
button so it is connected successfully.

32
00:02:23,400 --> 00:02:31,200
In order to see incoming logs, we should go to the lambda function, go to the monitoring and we logs

33
00:02:31,200 --> 00:02:32,400
in cloud logs.

34
00:02:34,100 --> 00:02:36,130
So we will see latest looks at.

35
00:02:37,040 --> 00:02:41,210
And yes, if you look at the latest look, expand this one.

36
00:02:41,420 --> 00:02:44,540
We will see the incoming event, JSON from the web socket API.

37
00:02:44,570 --> 00:02:46,310
One click the connect button.

38
00:02:46,340 --> 00:02:51,680
Please copy this box and paste into our visual code.

39
00:02:52,010 --> 00:02:58,130
So as you can see, we are in this stage in the connect integration and in the Connect integration,

40
00:02:58,130 --> 00:03:05,000
we get the logs and for that purpose we have an event connect JSON file, please paste in here, go

41
00:03:05,000 --> 00:03:11,360
to first line and remove the first line, save as a JSON format and see that this is the all incoming

42
00:03:11,360 --> 00:03:15,650
event which comes from the connection of the web socket API.

43
00:03:15,680 --> 00:03:23,090
If you scroll down, you can see that we have a request context and under request context we have a

44
00:03:23,090 --> 00:03:28,520
raw key and event key, which is the important attribute when we are communicating with the web socket

45
00:03:28,520 --> 00:03:30,230
API from the lambda function.

46
00:03:30,410 --> 00:03:36,110
So this is the event JSON object that triggered to a lambda function from the web socket API gateway.

47
00:03:36,200 --> 00:03:40,700
If you check this, we can find important parameters in here under request control.

48
00:03:40,730 --> 00:03:43,910
What key and event type is important attributes?

49
00:03:44,120 --> 00:03:50,090
According to these parameters, we can identify incoming root and the other details.

50
00:03:50,270 --> 00:03:56,030
So now we can send another connection, another root to the web API.

51
00:03:56,060 --> 00:03:59,360
Let me send a message to the request web socket API.

52
00:03:59,360 --> 00:04:06,500
And after that we have a see how to trigger from the lambda function and these will be the our chat

53
00:04:06,500 --> 00:04:07,070
application.

54
00:04:07,070 --> 00:04:09,670
So that's why I'm going to send a message.

55
00:04:09,680 --> 00:04:13,070
You can get the message from the command text of the lecture file.

56
00:04:13,100 --> 00:04:20,880
We can come here, we will use send message, copy this payload and come back to our test server.

57
00:04:20,900 --> 00:04:27,200
So now I'm going to send this test message, which is the encoding the action as a send message and

58
00:04:27,200 --> 00:04:28,430
this is the our customer load.

59
00:04:28,460 --> 00:04:32,930
This will be match and invoke our lambda function and click the send button.

60
00:04:33,410 --> 00:04:36,770
Yes, the sent message logs is created in here.

61
00:04:36,770 --> 00:04:39,170
So that means we have successful send message.

62
00:04:39,170 --> 00:04:45,560
So in order to see incoming event, we should go to the cloud watch logs of the our chat function lambda

63
00:04:45,560 --> 00:04:46,250
function.

64
00:04:46,250 --> 00:04:51,650
So in here open the latest log stream and come make the latest log stream.

65
00:04:51,650 --> 00:04:53,950
You can see that rod key is different.

66
00:04:53,960 --> 00:04:57,620
Copy this log and open the pseudocode.

67
00:04:57,650 --> 00:04:59,500
Go to this event.

68
00:04:59,900 --> 00:05:02,510
Send message JSON, paste in here.

69
00:05:02,840 --> 00:05:06,200
Go to first line of code and remove the first line.

70
00:05:06,200 --> 00:05:07,940
Save Jason.

71
00:05:09,140 --> 00:05:12,560
So this is the event JSON object that triggered lambda function.

72
00:05:12,560 --> 00:05:21,620
When we send message, you can see in here under the request context, we have rod key is sent message

73
00:05:21,620 --> 00:05:25,040
and we have a message ID, event type and so on.

74
00:05:25,040 --> 00:05:32,900
But this is the important that we can see the message of to our application integration in the body

75
00:05:32,900 --> 00:05:34,700
section, you can see the body section.

76
00:05:34,700 --> 00:05:40,430
This is the actual message that we sent from the our web socket client application.

77
00:05:40,430 --> 00:05:45,500
So you can see the body information, we can pass the information and perform our business logic.

78
00:05:45,590 --> 00:05:47,390
So this is the send message.

79
00:05:47,390 --> 00:05:50,240
And the last one is I'm going to show disconnect.

80
00:05:50,240 --> 00:05:55,460
So as you can see that now we are in the disconnect stage and we will trigger to disconnect out mf|p:I6.N>Ω9_$]rܹ	y7{|<3N
~<%%GN_qG1*44'`ٰPXKGs1k dzٯχ׳v켺㮚7;]3xf#;hH
P6sFʝcm[yqX XC$;-iSǻ:9c#f_/ΛcC6)ȸ;]bdi|r|"Ƥa}+<H(<6[,aZ*#	RHnԎpNqgDyoJ:!\U6@nL6355a3ڈ	?<mq}ƇFR=mbh=vvnt㾫,Sn@̄FX|ZQ>{I苆r}V;Nb(>Jı[gDc.ھbwfrgg@:seߡC6aS%bAUWc)Gٶu:owzQEj4%[?ÍD0;J|l#eF&RM9S5]݃mW%Pƥʕ+(>Hn{Ҭ_+|zh*nkbF`ܨSDT$3n-ȑP[-%@'JEA:/Ns~}>X٢N0TX**Jd2WiZeQc[	FC
;Y4qe"nT˲q1Nƙ)MOGfvU!#R0]p@5>bBv
rvm4qns@fr;AM9uԋx4gfM0Ke;6R	bNzn~vextg2c37dVble!3ǽdt9nUilvŃ-Ll,4))i?viz],j\C3֖SeuW(Hf#yۥ5 Jo)J`x*;{6amwzOŃ~m~զGd$djG:Ǖfgon-30tQyjw"%{WڑXc=kX:,'5mD|p2c{n	:vE'Nߗv̉7u=/j9{ ޅԌVQ-⮢hdX%Nz:bAm(fEq	cTذe$?l>+o,vќìg M#׎0JQtxlb7FO{X
;\`D/{OА{oۺ;װNBFG