Figure 4.1: structure of rasa processing in chatbot
RASA 2.8.0 RASA 2.8.0 Trained model: PhoBERT-base
82
4.7.2: Evaluation method
To evaluate the model in the problem of determining the intent and proper name in the NLU based on three metrics:
TP+FP_ TP TP TP+FN Precision =
Recall =
Precision.Recall
FI=2
Precision+Recall
actually positive actually negative <q
@ = TP
FN $ Precision = TP+LEP —
©
© (
© Recall = rp_£q = — ‘TP’ =.
©®
ằ classified (or found) as positive
°
Figure 4.5: Describe how the metrics evaluate the training model O Precision — is the percentage of how many corrects are retrieved,
Consideration of the dataset controls how much data is correctly judged by the model.
O Recall— the ratio of how many items are retrieved is correct, This metric is also known as coverage, it considers how generalizable the found model is.
From the two factors of accuracy and coverage, another index is established called Fl-Score
O Fl-Score: This is called a harmonic mean of the Precision and Recall standards. It tends to take the value closest to which is the smaller of the Precision and Recall values, and in parallel, it has a large value if both the Precision and Recall values are large. Therefore, Fl-Score represents a more objective way of a machine learning model.
4.7.3: Experiment
Experiment 1: Compare the models used in the intent and entity identification problem.
Whitespace Tokenizer: a model for separating tokens based on spaces or any other characters that are not displayed.
BERT: uses the surrounding text to provide the context to assist computers to grasp the meaning of ambiguous words in the text.
Roberta: This study set out to accelerate BERT architecture pre-training by optimizing the training process.
Algorithm Precision Recall Fl-Score
Whitespace 0,72 0,72 0,72
Tokenizer
BERT 0,74 0,73 0,78
Roberta 0.65 0,71 0.73
We have the intent confusion matrixes:
Table 5.0: Experiment result of three models
‘Tre label choose_major_categary
deny enralment_method enter_data it
help hưman handeffF major fst mathh_ask_reselt oi
‘out of scope react_segative react neutral
rcact positive
request_question restert scholarship
sleesy
thank
time_ask_date
hme ack aay tine _ack_manth tirre_esk_ timer fme_azk_year trendy chitchst tuitions wetcome
intent Confusion matrix
0 0 00 9 009 0 0 $9 0 000 9 0 0 00900 0 9 0 09 0 0 9 0 009 9 0 2 0 0 9 0 0 09 0 $€ 09 000 09 0 0 00 0 0 0 0 0 09 0 0 9 0 0 0 9 08 4đ 18 0 0 90 60 060 9 90 0 0 0 6 6 0 60 0 06 1086 0 ô2 0 0 g0 96 9 0 0D d6 9 oO 0 0 9 00 0 02 0 0 0 0 3 5 0 0 0 9 0 0 9 009 0 0 9 000 9 0 0 1 0 9 0 0 0 0 $ 0 0 0 0 0 0 0 0000 0 09 0 9 0 0 0 0 00 2 S0 ĐỆNH H67 tá 60660 eH Re ee RHR eS He
9 0 0 0 0 9 0 0 0 0 $9 0 00 0 0 0 0 00 00 0 09 0 0 0 90 0 00 09 8 ĐÔ 0 SN b6 6v 0 bán 6 6 61606 0606 00606 026 6806 9 Ch Se OR HRA Eee Eee AE COs ENS ERS
Ụ g 0 0 06 9 0 0 g0 ® 090 0 0 0 9 €0 000 0 0 0 0 0 0 0 0 9 0 DB 0
ụ coe so oo oH eo oe or oat eo eo we wo eo oo
9 0 2 0 0 9 0 0 0 0 9 0 0 0 9 0 0 0 0 9090 0 9 009 0 0 9 0 00
ụ |
" 00p 00 90p 0 0 96 0310000 6p 00 008p 09 0 00s 6n ng
9 0 0 0 0 9 0 0 0 0 $9 90 0 0 9 0 0 0 0 9 0 0 9 0 09 0 9 9 0 0 0
Đ g0 @ 018 9 0 BD @ 0 $ @ BD 0g 8.6 0 0 0 08 1 0 909 0 06 g0 9$ 9 BO Da
1 o 2 g0 18 9 0 D0 g0 08 6e @ p5 g6 0 6 bp g6 0 68 1n 0 9 2 0. g6 9 9 O Ba
9 0 6 0 4 9 0 0 0 0 $€ 09 000 09 9 0 0 09 0 0 9 0 9 0 0 9 0 0 0 ụ 0 9 a 9 9 0 6 Go eo ba oo Ho o ow De © oo eo OD 2 o 3 0 1 9 0 08 6 0 9 0 0 0 96 9 6 0 0 9 18 0 9 0 9 60 9 9 0 0 0 9 0 0 0 0 9 0 0 0 0 $9 9 000 9 6 8 9 0 0 09 0 9 9 0 9 09 0 09 9 8 0 06 0 9 0 0 060 0 9 0 0 0 0 60 60 0 0 0 MW 0 0 9 0 6 0 96 0 0 0 a
0 80 0 0 09 9 000 0 $ 90 9090 0 9 60 0 00969 0 9 0 0 06 9 9 0 0 0 9 0 0 0 0 09 0 0 0 0 $ 0 0 00 9 0 0 00 00 0 0 1 0 0 0 0 9 0 06 0 0 $ 90 00 0 9 6 0 009609 08 0
9 80 0 0 0 9 0 0 0 0 $€ 0 0 0 0 9 60 0 00 96 0 0 0 Ũ 0 0 0 0 909 0 0 0 0 fF 0 0 0 0 09 GC 0 090 0 09 0 0 9 8 0 0 0 9 0 0 0 0 $ 09 009 0 9 60 0 00909 0 06 9 0 0 0 09 9 0 909 0 0 $€ 90 0 0 0 9 60 00 0 909 0 0
" 0p 00 00p 0g 9 6000096000 01 ba
9 8a. n 019 9 008 0 0 $ 0 006 0 9 6 0 008 90 0a 6 9 a 0n @ 090 92 0 6 8a ứ 0 0 0 0 9 6 06 0 o 18 so 0
. @ 9 9 âằ ằ @ oe ap o 9 ôâ 9 ao @ p 9 8 9 â ằ 9 9 9
PSPEPPPECALTP gE ‘ ep LỆ FP Ee E g LT EL EL GPEPELLELEE EE Ễ Š RESET aoe ge 5 EES ASE DG ERE Ỹ Beg i as
s H Ễ g 2 £2 8 €Ee ti 2
Lš : z 2 š z = gs 8
Predicted labo!
Figure 4.6: Intent confusion matrix of BERT
85
True label,
intent Confusion matrix
aff 0 0 90 0 0 0 0 0 0 1 9 0 0 0 9 0 0 0.4 0 0 0 0 0 9 9 %9 0 0 0 09
bye | Ê 0 0 0 0 0 0 90 0 1 9 0 0 0 9 0 0 0 9 09 0 0 1 0 9 90 0 0 0 0 09
santhdp| 9 9 0 0 >ằ 0 000 00060090 0099 0 0 00 09. 0000. 6
dame] 0 eo eo eo oo to eo oo oe o oo ¢ 9 9 9% 0 0 0 09
đoose_nalor (ategay | 9 0 0 0 1 0 0 0 0 0 0 0 00090 00 9.09 0 U 0.0 0 9 0 0 0 00
sy}? 9 0 2 GIẢNG 6600000060620 66 Đo 6 0 0 0 9 9 9% 0 0 0 0
guatmemmanod| eo 6ử 9 ử0 0 |ỸŨ so 0 6 6 0 00 6 000 00 000000666 00 6 n.... 0/30 6206 D38: 0 02/62 9 (6° 187802078 6
et7® © 0 0 0 0 0 0 0 9 9 0 0 0 0 9 9 %0 0 0 0 09
@&plin |9 9 D 0 0ð 0p 0 9 6 dD 0 0 0ứ 0 0ứ 0 p0 oD a
guxj 0 op DO Đ 8 0289210 D09 0 8:20. 9 60878 8.8 8
hdpÐ 0 8 0 2 0 0 0 0 0 9 9 0 0 0 0 09 9 090 0 0 0 0
tuman hasdef 0đ 9 0 9 0 09 0ứ 0 0 9.90 0 0 0 9 9. 000006
amends. Đ Ăủ Đ Đ 60 06060 0966656590060 6 RàdGjiCRA| 2: Ð 26 8 8 on ovo ow OOo DO vo oo YG
a7? 9 © 90 0 0 0 0 0 9 9 0 0 0 0 0 9 9 0 0 0 09
@Lafscope| 9 90 0 1 0 0 0 000000009 0 0 0090 0 0 1 0 00 0000
Riđ gaho |9 6 ĐẾN n2 n p6 pp 6o on 6 GD G 60 b2 0 0n 6 02 p0 0o
ract cutai | 0 0 0 0 0 0 0 0 0 000900 0 0 900 ứ 0. 0 0 0 0 0 09 0 0 000
®actpostre| 9 9 9 1 0 0 0 00900 10909 090 a 0 0 0 0 9 0 00 00
mxzrÐ 0 0 0 0 0 0 0 0 0 0 0 6 09 0 0 9 0 00 0 929 0 0 0 0 9 090 0 0 0 0
ghoanhp| 9 9 0 b6 009 00666660 p 666906 bo bo b6 6b p6 60
sexy] © 9 0 900 0 0 0 9000000900099 0 Beet ea tess
Hay |3 60 9 0é 0é 6p p6 0 006 0p a02o0 o0 OM oo oo cử ễng ghdỏo| 9 910 9 0c G8 6 b6 p8 g0 00 6 0 d5 8 680 DẮẬNNG o3 6 ơn ử
time ask day | 0 9 0 0 0 0 0 0000000000 00 9090 0 00 0 0
tre sS monh | 9 0 0 0 0 2 0 b0 06 06 0009009690662 604 "so ỐnG xek ng | 9 9 0 8 00 0 00 600960009 06006 p9 006 0 0
tme ask year 0 9 0 0 0 0 0 00 0 0 0900090090 00 990 0 00 0 0
tendy chíchịt | 0 0 0 0 0 0 0 0900009000090 00990 0 0 9 0 6
Hãun| 9 9 0 9 09 0 09000 00 p0 00 0 00 69 0 0o ao
ee ee ee ee ee ee Đì 0 0/0: ee
EsreE RTE BEEF SET CR EGR ESE eR EB i 1ÿ? š
es REE"? ae eS °° FRh S5 SEER ETP SESE ERB E ag 35 ga 5 seg He TR OF B Ễ ÿ Ệ š @ g¢ Ễ 3§ ia E = Ể tp! tỆ Ễ B
|
Predicted label
Figure 4.7: Intent confusion matrix of whitespace tokenizer
86
19?
Intent Confusion matrix
atm 0 00 0000001 0000000 04 000009 00090009
10Ẻ bực 9 9 9 ụ 9 ụ ạ 9 9 1 w 9 ụ ụ ụ 9 6 ụ ụ o 9 o 1 9 ụ 0 o 0 9 o °
canthdpd 0 0 & 90 0 0000900090900 00 0060000090060 90000606
cha | 0 0: c0 ủ 00 0009019000002 0000090090609 0609
đhose major taegoy| 0 0 0 0 4205 0 0 0 060 60 000 06000000 606 0 0000606
dựny 9 9 9 9 0 9 0 9 ° o 0 o 9 ụ 9 0 ° o ũ 9 o oe 0 9
&rdimantmethed | 9 0 :9: 0 00 0 90 60 000090060689 00006009
eerie] œ z8: ỉ 0 0 0 9 0 00009000 60 0p 0000 0
et] 0 06 9 0 0 0 0 9 0 000 00 9090090 9 09
101
eplin| 9 0 9 9 0 0 0 0 0 0 00 00 00 90000009
greet 0 6 ° 9 ũ 9 0 ° © 0 ũ o a 0 ° 0 ° ũ a0 o 0 9 o °
hịp| 0 0 8 2 b0 0 06 000 @ 0 060, 60 0p 0p 6ú
luman handof| 0 0 0 0 0 00 00 000 0000900009060 9
tma|or_Ist 6 a 9 l o 9 o ° a 9.9 w 9 H 0 ụ ° ° o 0 ụ oe 9 oe a 9 o ụ 9 Ụ oe o 9
mạth ak em 0 © 9 © 0 9 0 © 6 @ @ 06 0 = 0 9 0 0 00000 900909060 9
|9 0 0 0 0ð ð 00 600 6 600g | 90 0 0 0 0 0 6 0 9 00096 0 g9 0 9
z 8 19!
actnegative, 9 9 0 4 0 2 0 00 900.9000906 0 0 0 0 0 090900090 9 09 ad neuai | 6 6 9 0 0 9 0 00 9060 0 9 00 0 9 6 K 8 0 6 0 60 9 0006 0 60 0
mat] 0 0 0 0 0 0 0009009090009 0 0 0100 00 9000900009
xielesHp|9 0 0 9 0 9 0 00090 0 09000 096 0000900 9 00 6000 ð
sepy|° @ 2 9 2 2 0 00 606 b0 90 0 00 6 6 00p 00 8 ứ 0 p0 0 @ aoe
ta 3 0 0 0 0 9000900 909000900 00000906 " 9 000 0009
tme ask dae | 0 0 0 0 0 0 0 00000 000090 000009 600 [pel 0 0 0 0.00 6 103
Eme.ask day | 9 0 0 0 0 9 0 00 000 90000 966 0006060 00 9 6 0 9 tứme a% manh | 0 0 90 0 0 0 0 00 00 b6 900009 6 00000 0ú o aa 0
tmesktime} 9 9 2 â D > n0 0o aằ 0b 0n 06 00p g0 0 006 a a 6
time ask yer| 0 0 0 0 0 0 0009000 9000900 000000096 o 0 0
wendy.chiretat| 0 0 0 0 0 2 0 @ © 900 00 000 6 © doe oo oa B oo
hiten] 9 9 0 0 0 2 oO 0ử â 0 0 0 @ 0 â â 2 â oO 6 0 oo eo oD â 0 O80 welcome| 0 0 0 9 0 0ứ 0 0 9.0 60 0 000 0 0 00 g gu 0.00 oo on
-———— 1p?
2 2 Ê ẩ 8 8 # Đ$ Ê SER SEO ÊỞ 5 E 5š t đ ẩ # ọ Đ ‡ÿ B # šĐ #
ER? š šÿ § 5 3È? 84 3 S$ BES § F BE $3225 28 #
fe 2 = 3 vi 5 a & 5 235 2 yf $228 FR ESBS % 6 8 8 8 Bs & wy Y ES 5 EES Eg 7g € 2 g
3 5 Ề 8 § 5S È „ 9 ở z 4 Se RR 8 $
ụ #5 © 3, Be pS ae Es 5 oe 3 Aes
e o£ eE g 4 F &@e@ 8 a ae
Ễ g £ 2 z š
Ÿ 5
5 Predicted labei
Figure 4.8: Intent confusion matrix of Roberta
The above confusion matrixes show which intent is confused with another.
Any patterns that have been incorrectly predicted will be recorded and saved for easier debugging.
Intent Prediction Confidence Distribution
Correct Wrong
Confidence
f 0.49 r 0.46 r 0.43 r 0.40 0.36:
0.33 0.30
+ 0.27
r 0.24
10000 8000 6000 4000 2000 0 0 1 2 3 4 5 6 7
Number of Samples
Figure 4.9: intent prediction confidence histogram
The histogram makes a difference to imagine the certainty levels for all expectations, with genuine and wrong forecasts, appearing in blue and ruddy bars, separately. Progressing the quality of your preparing information will move the blue histogram bars over the histogram and the ruddy histogram bars below the histogram. It'll too aidto decrease the number sum of ruddy histogram bars.
4.8: Evaluation
4.8.1: Experimental result
From the experimental results, some conclusions are drawn as follows:
88
oO Chatbots must prioritize determining the appropriate intent. For the closed domain problem, it is essential to establish precise intents, create a sizable data collection, label the data, and carry out training.
Building data, and training bots with scripts are essential for the chatbot's high accuracy.
Identifying and responding to multiple intents can be accomplished by combining intents.
Through the above experimental problem, applying chatbots to support users in the field of admissions counseling is feasible, highly practical, and can be applied in practice.
However, the implementation also encountered additional challenges including:
oO The issue of coreference is the first issue. We frequently shorten the names of the before-listed things in speech and writing. Vietnamese, for instance, allows speakers and authors to employ a variety of pronouns, regional slang terms, etc. if no data are available.It will be quite challenging for the chatbot to determine which object these phrases relate to without the aid of a context and co-referencing analyzer. The chatbot may interpret the user's interaction wrongly if the proper item isn't identified as to which the replacement term relates. Long chats make this problem very clear.
The variety in how people type user messages can make it difficult to understand their intentions. The chatbot must be able to handle both long and short sentences, as well as long content chat bubbles versus many very short submissions.
4.8.2: Participant’s rating
The author gave the product demo to 10 different participants, to see how satisfied each person was with the product. Of these, 50% were male and 50% were female.
The average of age was about 28 years. Because this demo of chatbot has only been posted on Messenger platform, so these participants used it on Facebook Messenger
(100%).
so
This evaluation report will have three main purposes:
O The satisfaction with enrollment information O The satisfaction with the entertainment O The diversity
The author will make an evaluation rating based on stars rating (from | star to 5 stars). After a few times of using this demo of chatbot, the chatbot was reported as follow:
O The overall stars rating of the satisfaction with enrollment information: 4.5/5 stars
O The satisfaction with the entertainment: 4 stars O The diversity: 4 stars
4.9: Demo of the chatbot 4.9.1: Run chatbot on terminal
To initialize the chatbot, we will first enter the venv environment:
\>. \venv\Scripts\activate (venv) C:\>
Figure 4.10: Create an environment in a chatbot
After entering the environment, access the folder containing the chatbot and start training data with the following command:
90
(venv) D:\chatbot-main>rasa train
Figure 4.11: RASA train command line
After entering the command, rasa will proceed to train the chatbot model as follows:
Conduct training for a model using NLU data and scenarios, the trained model will be saved as /models directory.
Figure 4.12: Training rasa After training the NLU, RASA will update the status as follows:
91
Figure 4.13: NLU training completed To test RASA on the terminal, we will include the following steps:
* Activate the server on Duckling
When declaring the pipeline in the config.yml file, the author declared the Duckling Entity Extractor item. Duckling lets you extract common entities like dates, amounts of money, distances, and others in several languages.
- url: URL of the running duckling server - dimension: is the dimension to extract
To activate the server htttp://localhost:8005, we open the DOCKER software, and activate the server as follows:
Pe cs Det Xt cả © sen
@ Containers / Apps
œ Imœc wonderful sutherland asa/cucklirgsa.
festive_greider rasa‘duchling
> ots SD
flambayant_hertz rasa/cuckiing
đẹp do001L.mdaren :se2/ducklng @ @ @ ©
ever_keller dockeriéay env
Figure 4.14: Start the duckling server
After the activation is complete, return to the terminal and enter the following commands:
Figure 4.15: rasa run actions command line
Rasa run actions will start a server using the RASA SDK, after the import is complete, RASA will report the following status:
Figure 4.16: RASA run actions completed
To load the trained model and talk to the chatbot on the command line, we use the command line like this:
(venv) D:\chatbot-main>ra
Figure 4.17: RASA shell Terminal will load the chatbot and show the following status:
Figure 4.18: Bot loaded 4.9.2: Connect chatbot to Facebook
For the chatbot to be presented in a more intuitive way, we will connect the chatbot to popular messaging platforms. In this project, the author has chosen the Facebook platform to present the chatbot most intuitively. The steps will be as follows:
Register for a Facebook Developer account and create a Chatbot app
First, we need to access the following link:https://developers.facebook.com/apps We need to create a Facebook account and log in, if you have already logged in before, then you don't need it anymore. Click on the REGISTER NOW button
3 é LÍ .
"_:::::aưaaan Register Now |
—-
Figure 4.19: Register for Facebook development A message appears, select REGISTER
94
Register as a Facebook Developer
Solomen Nguyen
Do you accept the Facebook Platform Policy and the Facebook Privacy Policy? =
— Cancel BEusics
Figure 4.20: Accept to be a Facebook developer The Facebook Developer user manual interface appears
€ C developers facebook. com/docs w 2# n9:
0@9Mete for Developers IMPORTANT
Documentation
Learn the basics of how to send and receive date from the Facebook Social Graph and how to implement the APis, Platforms, Products, and SDKs to fit your application needs.
App Development Graph API App Review
ir Th vay for apps to read and write Verify that your app uses our products and
tot Social Graph APIs in an approved manner.
Docs Docs
Docs
App Integrations Business Messaging Gaming SDKs
App Events 8 WhatsApp Business Platform © Games 8 Facebook SDK for Android ÍŸ
Figure 4.21: Facebook developer user manual interface The author has created a Facebook Developer account.
We will create a fanpage on Facebook as follows:
95
't%o
p Page Desktop Preview
Create a Page
CHATBOT TA ©° v e a
~y :
=
Business Consultant x © /
\
CHATBOT TA
ne Kine deos More * © Message
About Create post
@ Description
Tag Photo/video & 123 peop
Figure 4.22: Create fanpage on Facebook Click Create Page to finish creating the page
After creating a successful Page, Facebook will notify as follows:
Chatbot TA was created. Now you can add images or go to your Page to add more details.
Figure 4.23: Complete creating fan page
Q
Return to the interface of Facebook Developer, we will complete the registration, we click Create an app to create a new app.
Figure 4.24: Create an App interface
96
|
Next, fill in your app and email contact information, such as the Chatbot TA app and your personal email address.
Create an App X Cancel
@ Tre Provide basic information
Q9 Details Dieplay name
This is the app name associated with your app ID. You can change this later
App contact email
his email address is used to contact you about poten 10 recover the app if it's been deleted or
banhmynuong123@qmail.com
Business Account - Optional
© access Certain permissions or features, apps need to be connected to a Business Account
No Business Manager account selected xv
By proceeding, you agree to the Facebook Platform Terms and Developer Policies. Previous } create app |
Figure 4.25: filling the information for the app After creating the app, Facebook will redirect to the interface as follows:
po MetaforDevelopers CSS
G) crswwor 14 app - App ID: 1058479521424462 App type: Business @®)Hep
{a} Dashboard
{8} Settings Add products to your app
Kì) Roles *
An . © © @
â App Review ằ App Events Audience Network Facebook Login
A44 Peod.et
Setup setup Setup
= tivity ụ
Fundraisers Instagram Graph API Jobs
sep Setu se
Figure 4.26: Complete creating the app
The top left corner will be the name of the chatbot you just created, the app ID, and the App type.
Go to the Add products to your app section, go to the Messenger section and press Set up
Messenger
act with people on
Read Docs Set up
Figure 4.27: Messenger section
A new screen opens with a lot of information, including an introduction to Messenger, scroll down to the Access Token section.
Access Tokens Create new Page
Generate a Page access token to start using the platform APIs. You will be able to generate an access token for a Page if
1. You are one of the Page admins, and
2. The app has been granted the Page's permission to manage and access Page conversations in Messenger.
Note: If your app is in dev mode, you can still generate a token but will only be able to access people who manage the app or Page.
No page permissions granted
You'll need to connect pages and grant them the required permissions in order for tokens to be generated.
Figure 4.28: Access Tokens
Click “Add Remove Pages” to select the fan page you just created above
98
©} Log in win Facebook - Google Chrome ~ OG x
@ facebook. com‘dialog/oaulh?response_lypeickendudisolay-popupsiclientid... ®
Ww Tuần Anh #
All Pages (5) saect4l M
"natbot Tí fe Chatbot TA
` 111008704980001
E Tachatbot Aint aaa
al Trang Tuần Art\ ;
106682750669285¢ "
i Tuần Arh 2a
720002838104557
N Nhịn Cười.
4 315É
Cancel Next
Help Center
Figure 4.29: Choose the app
And we have created a chatbot app and linked the app to the fan page, which means that our chatbot will oversee receiving and replying to messages for the fan page we just created.
@ Log in With Facebook - Google Chrome. = Oo x
@ facebook.com/dialog/oauth?response_type=token&display=popup&client_id... &)
œ® = Tuấn Anh w
You've now linked Chatbot TA app to Facebook
You can update what Chatbot TA app can do in your Business Integrations Settings. To finish setup, Chatbot TA app may require additional steps.
Figure 4.30: Complete linking app to Facebook
99
Next, we will configure Facebook Messenger and RASA. First, we get the Access Token, we click the Generate Token button in the image above and then click the tick, copy the Access Token to one place, and save it temporarily.
Token generated x
Chatbot TA 111008704980091
To protect your security, ONLY share this token with app developers you trust.
This token will only be shown once, so keep it safe. If it gets lost, you'll need to create 4 new one. Anyone could potentially use this token to impersonate this page, depending on the privacy settings of your app. If you wish to revoke all previously generated tokens for this app, you can go to Business Integrations settings. Learn More (v) | Understand
EAAPCrnfgZAE4BADMybBn7espusAasdjtlửdGAgQ0CuOkd2kFUOmkswNCXgU1R.. (R copy
Figure 4.31: Token generated
Continue, we will get the App secret, click on the left menu, select Settings, select Basic and look to the right to see the App Secret box, click Show and copy, also save it in 1 place.
Chatbot TA 0p * App ID: 105847952142446 App type: Busin Oreo
(Gy Dashboard App ID App secret
4d R
2 Settings a
Basle Display neme Namespace
Advanced ^
3H) Re v
ay Ses App domains Contact email
^ Privacy Policy URL Terms of Service URL
) App Review v
Facebook Login x Choose a category +
Messenger v
Log t= Activity Log
Figure 4.32: Get the App secret
100
Next, we will choose an arbitrary text (for example: “mybot”,
“abc123”,”12345a@”’...) to make the test code for the webhook. Here we choose
"mybot", also save a place to it, will use it later.
After having the above 3 information, we find the file credentials.yml, open it and fill in the following information:
After filling in, we save and move to the next step, install the software Ngrok When we run the RASA server on your computer, it will open the port at
http://localhost:5005
localhost:5005 port like this, Facebook in the US cannot call our server. So, we need a tool to connect from your device to an address outside the Internet and Facebook can call, that is Ngrok.
Now we go to https://ngrok.com/, and download the software depending on the operating system. Roughly after that, we will have a Ngrok file to run (if it's a window, add the .exe extension)
Next step, we will run RASA, enable Ngrok and test the connection We will run the following command to start the RASA server at localhost:
Figure 4.33: rasa runs server When running successfully, the terminal will appear as follows:
Next, thanks to Ngrok! We go to the folder containing the Negrok file, open the command line and type the command
101
ngrokHTTP 5005 The software will appear as follows:
đ' C:\Users\ADMIN\Desktop\ngrokexe - ngrok http 5005 — ủ x
Figure 4.34: Complete convert http:// to https:// on ngrok
We will notice that we will see 2 Forwarding lines, that is the address where Nerok shows RASA to the internet for Facebook to identify and connect. Having both HTTP and HTTPS addresses, we will only be interested in the HTTPS one.
).ngrok.io
Figure 4.35: converted server link HTTP://
Now we open a web browser and type in the HTTPS address, if the access is successful, it means the mapping has been successful.
¢ Cf O0d0-171-229-222-253 ap ngrokio ae TO 0
102
Figure 4.36: Mapping successful
In the last part, we go to http://developers.facebook.com and select the Facebook
App
we created, select Messenger, and select Settings. You find the Webhook section and
select Add Callback URL:
Webhooks
To receive messages and other events sent by Messenger users, the app should enable webhooks integration Add Callback URL
Figure 4.37: Add Callback URL
Enter the address Ngrok and add the correct extension as shown (from the webhooks....), below enter the test code that we have devised above, here it is
"mybot".
Callback URL
https://00d0-171-229-222-253.ap.ngrok.io/webhooks/facebook/webhook
Verify token
= |
Learn more Cancel Verify and save
Figure 4.38: Verify and save the app
Then click Verity and Save and you're done. If there are no problems, Facebook will redirect to the interface like this:
103
Webhooks
To receive messages and other events sent by Messenger users, the app should enable webnooks integration
Callback URL Varily token
https:00d0-171-229-222-253 ap namk iovwebhooks/facebookhwabhook
Validation requests and Webhook notifications ‘or this object willbe sent Token that Meta will echo back to you as part of callback URL
to this URL. verification.
Edit callback URL [ẹ Show recent errors
Pages t
Chafbnt TA O fields
Add or remove Pages [Gi]
Figure 4.39: Done editing the webhooks
After adding the Webhook, we select the Edit button in the image below and tick the two messages and message_postbacks and save again:
Edit page subscriptions x
Chatbot TA 111008704980091
Subscription Fields
x⁄. messages messaging_postbacks messaging_optins
messaging_optouts message_deliveries message_reads
messaging_payments messaging_pre_checkouts messaging_checkout_updates
messaging_account_linking messaging_referrals message_echoes
messaging_game_plays standby messaging_handovers
messaging_policy_enforcement message_reactions inbox_labels
messaging_feedback messaging_customer_information whatsapp_messages
Learn more Cancel ES
Figure 4.40: Edit page subscriptions
Now we can use Facebook nick to create a Fanpage to test chatting with a chatbot
104