furniture online ordering using chatbot · furniture online ordering using chatbot was developed to...

87
FURNITURE ONLINE ORDERING USING CHATBOT INTAN NADIRAH BINTI AHMAD BACHELOR OF COMPUTER SCIENCE (SOFTWARE DEVELOPMENT) WITH HONOURS UNIVERSITI SULTAN ZAINAL ABIDIN 2019

Upload: others

Post on 28-Feb-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

FURNITURE ONLINE ORDERING USING CHATBOT

INTAN NADIRAH BINTI AHMAD

BACHELOR OF COMPUTER SCIENCE

(SOFTWARE DEVELOPMENT) WITH

HONOURS

UNIVERSITI SULTAN ZAINAL ABIDIN

2019

Page 2: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

FURNITURE ONLINE ORDERING USING CHATBOT

INTAN NADIRAH BINTI AHMAD

BACHELOR OF COMPUTER SCIENCE

(SOFTWARE DEVELOPMENT) WITH HONOURS

FACULTY OF INFORMATICS & COMPUTING

UNIVERSITI SULTAN ZAINAL ABIDIN

JANUARY 2020

Page 3: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

i

DECLARATION

I hereby declare that this report is based on my original work except for quotations

and citations, which have been duly acknowledged. I also declare that it has not been

previously or concurrently submitted for any other degree at Universiti Sultan Zainal

Abidin or other institutions.

____________________________

Name : Intan Nadirah Binti Ahmad

Date : ……………………………..

Page 4: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

ii

CONFIRMATION

This is to confirm that this final year project entitled Furniture Online Ordering

using Chatbot has been prepared and submitted by Intan Nadirah Binti Ahmad ,

with matric number BTAL17046608 and has found satisfactory in terms of

scope, quality, and presentation as a part of the requirement for the Bachelor of

Computer Science in Software Development in University Of Sultan Zainal

Abidin (UniSZA). The research conducted and the writing of this report was

under my supervision.

_________________________________

Name : Prof. Madya Dr. Engku Fadzli Hasan

Bin Syed Abdullah

Date : ……………………………………….

Page 5: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

iii

DEDICATION

I am using this opportunity to express my gratitude to everyone who has

supported me in completing my final year project Furniture Online Ordering, using

Chatbot successfully. I am thankful for their aspiring guidance, invaluably

constructive criticism and friendly advice during this project work.

I express my greatest gratitude to my supervisor, Prof. Madya Dr. Engku

Fadzli Hasan Bin Syed Abdullah, who helps in guiding me throughout my journey in

finishing this project. Under his supervision with a lot of advice, I was able to

complete this final year project successfully. Then, important respect I present to my

family especially my parents for their understanding of my conditions.

I would also love to thanks all my friends and my course mates for supporting

me and gave me an aspiration to improve this project. I want to thank all the people

for their help, whether it was directly or indirectly, to complete this project.

Page 6: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

iv

ABSTRACT

Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get

closer to customers. This chatbot may be able will help the seller to promote their

products, engage customers, and boost revenue. Then, it also can assist the customer

throughout the purchase process to make purchases more easily. It is a demand

nowadays, where it can save time and effort by automating customer support. The

RAD method is used in this project to ensures that the development of the system runs

smoothly and according to planning. This model has four main phases, which are

Analysis and Quick Design, Prototype Cycles, Testing, and Deployment. The

expected result for the following proposed project is the user can choose any answer

that has been provided by the chatbot system and make a booking. Then the user will

be able to communicate with the chatbot anytime.

Page 7: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

v

ABSTRAK

Pesanan perabot secara atas talian menggunakan Chatbot telah dibangunkan untuk

membantu para usahawan untuk lebih dekat dengan para pelanggan. Chatbot ini dapat

membantu penjual mempromosikan produk mereka, melibatkan pelanggan dan

meningkatkan pendapatan. Kemudian, ia juga dapat membantu pelanggan sepanjang

proses pembelian untuk membuat pembelian lebih mudah. Ini adalah permintaan pada

masa kini, di mana ia dapat menjimatkan masa dan usaha dengan mengautomasikan

sokongan pelanggan. Kaedah RAD digunakan dalam projek ini untuk memastikan

pembangunan sistem berjalan lancar dan mengikut perancangan. Model ini

mempunyai empat fasa utama, iaitu Analisis dan Rancang Pantas, Siklus Prototaip,

Pengujian dan Penyebaran. Hasil yang diharapkan untuk projek yang dicadangkan

berikut adalah pengguna dapat memilih apa jawapan yang telah disediakan oleh

sistem chatbot dan melakukan pemesanan. Kemudian pengguna akan dapat

berkomunikasi dengan chatbot pada bila-bila masa.

Page 8: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

vi

CONTENTS

DECLARATION i

CONFIRMATION ii

DEDICATION iii

ABSTRACT iv

ABSTRAK v

CONTENTS vi

LIST OF TABLES viii

LIST OF FIGURES ix

LIST OF ABBREVIATIONS / TERMS / SYMBOLS xi

CHAPTER 1 1

INTRODUCTION 1

1.1 Introduction 1

1.2 Problem Statement 2

1.3 Objectives 2

1.4 Scopes 3

User Scope 3 1.4.1

System Scope 4 1.4.2

1.5 Limitation of Work 4

1.6 Expected Result 4

CHAPTER 2 5

LITERATURE REVIEW 5

2.1 Introduction for Chatbot 5

2.2 Introduction for Telegram 6

2.3 Related Research Technique and Tools 7

CHAPTER 3 10

METHODOLOGY 10

3.1 Introduction 10

3.2 Project Methodology 11

Page 9: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

vii

Phases in Rapid application development model 12 3.2.1

3.3 System Requirement 14

3.4 System Design 15

Framework Design 15 3.4.1

Context Diagram 17 3.4.2

Data Flow Diagram 18 3.4.3

Entity Relationship Diagram 20 3.4.4

3.5 Data Dictionary 21

CHAPTER 4 23

IMPLEMENT AND RESULT 23

4.1 Introduction 23

4.2 Interface Design 24

Staff 24 4.2.1

Customer 32 4.2.2

4.3 Implementation 39

Test Cases 39 4.3.1

Test 40 4.3.2

4.4 Feasibility Survey 43

CHAPTER 5 48

CONCLUSION 48

5.1 Introduction 48

5.2 Project Contribution 48

5.3 Project Constraints and Limitation 49

5.4 Future Works 49

5.5 Conclusion 49

REFERENCES 50

APPENDIX 51

APPENDIX A (GANTT CHART 1) 52

APPENDIX B (GANTT CHART 11) 53

APPENDIX C ( CHATBOT CODING ) 54

Page 10: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

viii

LIST OF TABLES

TABLE TITLE PAGE

3.1 Hardware used in this project 14

3.2 Software used in this project 14

4.1 Test Case for Login 40

4.2 Test Case for Add Furniture 41

4.3 Test Case for Update Furniture 42

Page 11: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

ix

LIST OF FIGURES

FIGURE TITLE PAGE

2.1 Chatbot Operations 6

3.1 Rapid Application Development Model 11

3.2 Framework 16

3.3 The Context Diagram (CD) 17

3.4 Data Flow Diagram Level 18

3.5 Data Flow Diagram Level 1 for Booking process 18

3.6 Data Flow Diagram Level 1 for Payment process 19

3.7 Entity Relationship Diagram (ERD) 20

3.8 Data Dictionary for Booking 21

3.9 Data Dictionary for Customer 21

3.10 Data Dictionary for Furniture 21

3.11 Data Dictionary for Payment 22

3.12 Data Dictionary for Staff 22

4.1 Login Interface 24

4.2 Homepage Interface 25

4.3 Profile Staff Interface 26

4.4 Update Profile Staff Interface 26

4.5 Manage Furniture Interface 27

4.6 Add Furniture Interface 28

4.7 Update Furniture Interface 29

4.8 Booking Report Interface 30

4.9 Payment Report Interface 30

Page 12: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

x

4.10 Booking Report Interface 31

4.11 Payment Report Interface 31

4.12 Customer Register 32

4.13 Main Menu 33

4.14 List of product 33

4.15 Details of the product 34

4.16 Ordering Product 35

4.17 Order Details 35

4.18 Payment Details 36

4.19 Payment Process 36

4.20 Update Address Process 37

4.21 Cancel Process 38

4.22 Result of Feasibility Survey 44

Page 13: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

xi

LIST OF ABBREVIATIONS / TERMS / SYMBOLS

CD Context Diagram

DFD Data Flow Diagram

ERD Entity Relationship Diagram

FYP Final Year Project

RAD Rapid Application Development

Page 14: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

1

CHAPTER 1

INTRODUCTION

1.1 Introduction

A Chatbot is an assistant that communicates with the user through text

messages, a virtual companion that integrates into websites, applications, or instant

messengers and helps entrepreneurs to get closer to customers. Such a bot is an

automated system of communication with users. It is a demand nowadays, where it

can save time and effort by automating customer support. In this case, the chatbot for

Furniture Online Ordering using Chatbot is proposed to enhance the relationship with

the customer. This chatbot will help the seller to promote their products, engage

customers, and boost revenue. Then, it also can assist the customer throughout the

purchase process to make purchases more easily.

Page 15: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

2

1.2 Problem Statement

Customer relationships are the most important of today, and problems arise

when sellers take a long time to provide feedback to customer inquiries. Customers

have to wait a long time for the response that will affect their purchase decision.

Moreover, there is no faster platform for customers to communicate with the seller

except with the message. They need to have a company number to do so. Finally,

customers are more comfortable chatting online, which makes them willing to type

orders and talk to a bot. This is because, with fast feedback, it can facilitate and

expedite their dealings.

1.3 Objectives

In general, the purpose of Furniture Online Ordering using Chatbot System is

to help customers to make purchasing easier and faster. Besides, it also assists the

customer in knowing the details about the furniture. The objectives are defined as

below to design a chatbot that contains information about furniture. Next, to develop a

chatbot that answers quickly and efficiently for some questions from the customer.

Finally, to test the functionalities of the proposed system, either it able to meet the

requirement.

Page 16: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

3

1.4 Scopes

The scope is going to outline the uses and functions of this application system

and make the implementation easier. The scope of this system is divided into two,

which are user scope and system scope.

User Scope 1.4.1

1.4.1.1 Customer

• The system shall allow the user to start the conversation.

• The system shall allow the user to choose the answer option from the system.

• The system shall allow the user to view the information about the furniture.

• The system shall allow the user to make a booking.

• The system shall allow the user to cancel the product before making a

payment.

1.4.1.2 Staff

• Staff can add new furniture and update the furniture data.

• Staff can view customer bookings.

• Staff can view the payment status.

• Staff can send a notification to the customer.

Page 17: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

4

System Scope 1.4.2

• The system shall be able to respond to the questions that choose.

• The system shall be able to show the information about the furniture.

• The system shall be able to accept the booking from the user.

• The system shall be able to update the stock in the database.

1.5 Limitation of Work

There are limitations and constraints that occurred throughout the development

of this online chatbot. These problems and limitations in conducting this study are the

chatbots have a very limited dictionary where it is only able to understand a certain

question that has been asked by the user.

1.6 Expected Result

The expected result for the following proposed project is a chatbot that can

help the seller to promote their products, engage customers, and boost revenue. Then,

it also can assist the customer throughout the purchase process to make purchases

more easily.

Page 18: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

5

CHAPTER 2

LITERATURE REVIEW

2.1 Introduction for Chatbot

A chatbot is artificial intelligence (AI) software. It is a promising expression of

the interaction between humans and machines that only represents the natural

evolution of a Question-Answering system leveraging Natural Language Processing

(NLP). Then, it has been used to simulate a conversation or a chat with a user in

natural language. Chatbot often used through messaging applications, websites,

mobile apps, or through the telephone. The chatbot is a very important application that

can streamline interactions between people and services that enhance the customer

experience. It also offers new opportunities to many companies to improve customers

engagement process and operational efficiency that can reduce the typical cost of

customer service

Page 19: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

6

Figure 2.1 illustrates how a chatbot operates and responds to the question.

First, the chatbot will accept the input from a user. Then, it analyzes the user‟s request

to identify the user intent and to extract relevant entities. When the user‟s intent has

been identified, the chatbot composes an answer and replies to the user‟s request.

Figure 2.1 : Chatbot Operations

2.2 Introduction for Telegram

Telegram is a cloud-based mobile and desktop messaging app with a focus on

security and speed. It uses end-to-end encryption by mean that all data sent and

received via Telegram cannot be deciphered when intercepted by ISPs, network

administrators, or other third parties. Telegram is for everyone who wants fast and

reliable messaging and calls. Telegram lets the user send messages, photos, videos,

and files of any type and create groups for up to 200,000 people or channels for

broadcasting to unlimited audiences. Business users and small teams may like large

groups, usernames, desktop apps, and powerful file-sharing options.

Analyze

request

Identify intent

and entities

User

input

Compose

reply

Page 20: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

7

2.3 Related Research Technique and Tools

The first related works are form article [1]. ALICE Chatbot is the Artificial

Linguistic Internet Computer Entity that came from Wallace in 1995. In the ALICE

architecture, alternative language knowledge models can be plugged and played

because the chatbot engine and the language knowledge model are separated. The

advantages of ALICE are its deliberate simplicity of the pattern-matching algorithms

and rely on a very large number of basic categories or rules matching input patterns to

output templates. Then, ALICE also more advanced because of the number of simple

rules is large to make up for lack of morphological, syntactic, and semantic NLP

(programming language) modules. However, the main lack in ALICE is it needs to

develop the knowledge manually.

The second article [2] is about Chappie, a semi-automatic intelligent chatbot

that was developed to meet the requirement from a business side and desire for

efficiency and automation. Chappie can be used as a routing agent that can classify the

requirement of the user. It changes it into one of the services provided by business

through the first few chats than transfer it to an agent expert in that service. The good

thing about Chappie is it has been designed smartly to extracts all sorts of information

such as name, intent, mail, city, et cetera, and generates a coherent response to the

user, but it needs more sophisticated algorithms to extract intent and classify chats

more accurately.

Page 21: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

8

The third article [3] is DocChat, a novel information retrieval approach for

chatbot engines. It was used to leverage unstructured documents, instead of Q-R pairs

to respond to speech. The features of these models depend on existing resources that

are readily available such as Q-Q pairs, Q-A pairs, „sentence-next sentence‟ pairs, and

et cetera instead of requiring manually. Second, it was very good in adaptation

capability where it can learn internal relationships between speech and responses

based on statistical models. Regardless of all of that, collecting such QR pairs is

intractable for many specific domains.

AliMe Chat [4] is the next article about an open-domain chatbot engine that

integrates the joint results for Information Retrieval (IR) and Sequence to Sequence

(Seq2Seq) based on generation models. To optimize the joint results of IR and

generation models, it uses a novel hybrid approach. Then, it shows that the approach

outperforms both IR and generation. The engine shows better performance afterward.

AliMe Chat is used for a real-world industrial application. Unfortunately, Seq2Seq

generation models tend to generate inconsistent or meaningless answers and do not

scale up well according to context-aware techniques in some situations. Lastly, AliMe

Chat is lack of personification like empowering the chatbot with characters and

emotions.

Page 22: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

9

The next article is MILABOT, a deep reinforcement learning chatbot [5] that

was developed by the Montreal Institute for Learning Algorithms (MILA) for the

Amazon Alexa Prize competition. It was well-known for its ability that capable of

conversing with humans. Then, the system consists of natural language generation and

retrieval models, including neural network and template-based models. MILABOT

also has been trained to only choose an appropriate response with reference to the

models in its group. Through the testing that has been performed on the system that

involves a real-world user, it shows that the system performed significantly better than

other systems.

Last but not least is Pandaibot, a boat for Telegram that builds as a side project

to provide convenience to all in some cases. Functions that available in Pandaibot are

animated pictures and pictures, prayer times in Malaysia, and also functions to check

postage delivery status. Among the advantages of Pandaibot is that users can check a

delivery status from PosLaju, SkyNet, City Link and GD Express via Telegram

without leaving the messaging app. In addition, users can also check the time of the

prayer, use the dictionary, and read the news from several portals and also check the

weather. PandaiBot also allows users to search for images and GIFs directly via

Telegram. However, Pandaibot has a very limited dictionary where it only allow the

user to choose the answer option that has been provided.

Page 23: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

10

CHAPTER 3

METHODOLOGY

3.1 Introduction

This chapter will discuss the methodology used to develop this system.

Therefore, the rapid application development model is used for Furniture Online

Ordering using Chatbot System. This model explains more detail about every phase

that involve in this project development to make sure this system developed

successfully. Furthermore, this chapter also explains the justification for the use of

methods and technique as well as hardware and software requirement during this

project. Besides, this chapter contains a Context Diagram (CD), Data Flow Diagram

(DFD), and Entity Relationship Diagram (ERD) for this project.

Page 24: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

11

3.2 Project Methodology

Methodology is a method used to develop a system. A good planning and

methodology must be used to accomplish the objectives of this project. The rapid

application development model has been chosen as the methodology to develop this

system. The benefits of rapid application development are changing requirements that

can be accommodated, and progress can be measured. Besides, iteration time can be

short with the use of powerful RAD tools. The flexibility of the model makes the

development time reduced and increases the reusability of components. Hence, the

rapid application development model encourages customer feedback. Figure 3.1

below shows the Rapid application development model. This model has four main

phases, which are Analysis and Quick Design, Prototype Cycles, Testing, and

Deployment.

Figure 3.1 Rapid Application Development Model

Page 25: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

12

Phases in Rapid application development model 3.2.1

3.2.1.1 Analysis and Quick Design Phase

During this phase, all the modules will be design based on Furniture

Online Ordering using the Chatbot system. The analysis and quick design

phase is the most important phase to make sure the module development is

properly planned. In the analysis phase, the detailed about this proposed

system was discussed. Problem statements, objectives, system‟s scope, and

limitation of work were defined as well. The quick design of the Furniture

Online Ordering using Chatbot System was conducted by reviewing the

journal.

3.2.1.2 Prototypes Cycles Phase

This phase is to ensure that the project met every planning that has

been discussed in the Analysis & Quick Design Phase. A prototype design for

module customers view and check furniture information, booking, and

payment will be developed. Each module will go through the developed,

demonstrate, and refine the phase before proceeding to the testing phase.

Page 26: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

13

3.2.1.3 Testing Phase

In this testing phase, prototypes for each module in Furniture Online

Ordering using Chatbot, systems are converted from the design phase into the

working model. The phase breaks down into several smaller steps like

preparation for rapid deployment, program and application development,

coding, unit, integration, and system testing.

3.2.1.4 Deployment Phase

This is the implementation phase. The finished product of Furniture

Online Ordering using Chatbot goes to launch. It includes data conversion,

testing, and changeover to the new system, as well as user training. The

objectives of this stage are to install the system in production operation with

minimal disruption of normal business activity, to maximize the effectiveness

of the system in supporting the intended business activities. Next, identify

potential future enhancement.

Page 27: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

14

3.3 System Requirement

The requirement of hardware and software are the most important part of some

project because it will guide to the successful project. The hardware and software

requirements used in this project are shown in Table 3.1 and 3.2 below :

Table 3.1 Hardware used in this project

No Hardware Specification

1 Laptop Processor : AMD A-10-8700P

Radeon R6, 10 Compute Cores

4C+6G 1.80GHz

Installed memory (RAM) : 4.00GB

2 Mouse For making easy tasks and faster to

click when developing the project.

3 Pendrive To store the backup file

Storage : 32GB

4 Printer Canon MP287 To print out the documentation

To print picture dictionary

Table 3.2 Software used in this project

No Software Specification

1 Xampp To create a table and database

2 MySQL To save the data in the database.

3 Notepad++ To make coding for the system

4 Microsoft Word 2010 To make a proposal and thesis

5 Edraw Max To create Context Diagram(CD),

Entity Relationship Diagram(ERD)

and Data Flow Diagram(DFD)

Page 28: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

15

3.4 System Design

Developing a planned system is a process and planning activity in designing

the system. This design was made to improve the existing system after its weakness

was identified through the results of the investigation and previous analysis. In

Furniture Online Ordering using Chatbot System, the context Diagram (CD) and Data

Flow Diagram (DFD) act as physical design while Entities Relationship Diagram

(ERD) acts as a logical design.

Framework Design 3.4.1

A framework is a real or conceptual structure that use to serve as a guide to

expands the structure into something useful. A framework may be for a set of

functions within a system and how it interrelates between the layers of an operating

system, the layers of an application subsystem, and how communication should be

standardized at some level of a network. The framework shown in Figure 3.2 below

shows how the system responds to the user question.

Page 29: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

16

First, a user will use the telegram application to interact with the chatbot. Next,

users can request bots to view the furniture information, and the chatbot will accept

the input and identify the user intent to extract relevant entities. When the user‟s intent

has been identified, the chatbot composes an answer and replies to the user‟s request.

The user also can make a booking process through the chatbot and cancel it before

making a payment process. The chatbot will save the booking and payment

information into the database.

In addition, staff also can manage the furniture information through the

system. They can add new stock, update, and view the furniture information that has

been stored in the database. For the booking and payment report, staff can request to

view the information on a specific date. The data will be gathered from the database

and replies to the staff‟s request.

Figure 3.2 Framework

Page 30: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

17

Context Diagram 3.4.2

The Context diagram is a Data Flow Chart that shows the scope and boundaries

of an information system. It usually shows the entities and processes involved in the

system to be redesigned, which illustrates how moving from one process to another. It

is the first figure drawn before the Data Flow Chart.

In Furniture Online Ordering using Chatbot System, it can be identified how

this system works. Among the major entities in the system are customers. The context

diagram in Figure 3.3 below shows customers to input their information as requested,

customer input the details of the furniture they want to see, then make a booking and

payment.

Figure 3.3 The Context Diagram ( CD )

Page 31: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

18

Data Flow Diagram 3.4.3

3.4.3.1 DFD Level 0

The Data Flow Chart is an overview of the overall system trip diagram

in detail and overall. It helps the user to understand the flow of the system

built. The first process is the customer authentication process in the order.

After conducting the validation process, the customer will go through the other

means to view furniture information. Then the customer will input their data

into the system which is the third process. Then the customer made the fourth

process of booking the furniture and then the customer made the payment the

fifth process.

Figure 3.4 Data Flow Diagram Level 0

Page 32: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

19

Figure 3.5 Data Flow Diagram Level 1 for Booking process

3.4.3.2 DFD Level 1

3.4.3.2.1 Booking

Figure 3.5 shows the DFD Level 1 for the booking process. The

customer can make a booking and will be stored in the booking

database.

3.4.3.2.2 Payment

Figure 3.6 shows the DFD Level 1 for the payment process. The

customer can make a payment and will be stored in the payment

database.

Figure 3.6 Data Flow Diagram Level 1 for Payment process

Page 33: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

20

Entity Relationship Diagram 3.4.4

The Entity-Relationship Diagram (ERD) is a graphical representation of an

information system that shows the relationship between people, objects, places,

concepts or events within the system. The ERD of Furniture Online Ordering using

the Chatbot System project consists of four table entities such as Customer, Booking,

Furniture, and Payment. The ERD of Furniture Online Ordering using Chatbot System

shown in Figure 3.7 below.

Figure 3.7 Entity Relationship Diagram (ERD)

Page 34: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

21

3.5 Data Dictionary

The database in the main part of the system development because it will store the data

that are used by the system. The list of tables involved in this system are list as figure

3.8 until figure 3.12 below :

Figure 3.8 Data Dictionary for Booking

Figure 3.9 Data Dictionary for Customer

Figure 3.10 Data Dictionary for Furniture

Page 35: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

22

Figure 3.11 Data Dictionary for Payment

Figure 3.12 Data Dictionary for Staff

Page 36: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

23

CHAPTER 4

IMPLEMENT AND RESULT

4.1 Introduction

Implementation and testing are executed for ensuring that the system developed

according to user requirements. The process carried out in this phase involved

building a system interface so that the operation can function entirely and user-

friendly with the help of a complete user manual. This phase also a process of defining

how the information system can achieve the main objectives of the order before it can

be delivered to the user.

In order to achieve the objective of the system, a few of the testing approaches

have been carried out, which include unit testing, integration testing, and system

testing.

Page 37: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

24

4.2 Interface Design

Staff 4.2.1

4.2.1.1 Login Interface

Figure 4.1 Login Interface

Figure 4.1 shows the staff login page for Furniture Online Ordering

using Chatbot. Staff is required to fill in their Staff Id and Password to login to

the system. This page displays the main interface of the system.

Page 38: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

25

4.2.1.2 Homepage Interface

Figure 4.2 Homepage Interface

Figure 4.2 shows the homepage interface for Furniture Online Ordering

using Chatbot. It will be shown after the staff success login into the system.

Page 39: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

26

4.2.1.3 Profile

Figure 4.3 Profile Staff Interface

Figure 4.4 Update Profile Staff Interface

Figure 4.3 and figure 4.4 are the interfaces for staff to update their

profile, such as name or password, but they cannot change their Staff id.

Page 40: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

27

4.2.1.4 Manage Furniture

Figure 4.5 Manage Furniture Interface

Figure 4.5 shows the interface for staff to manage the furniture stock in

the database. Staff can view the list of the furniture stock in the database and

add the new furniture details or update the furniture details.

Page 41: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

28

Figure 4.6 Add Furniture Interface

Figure 4.6 is the interface for staff to add new furniture details. Staff is

required to fill the information on the product, as shown above.

Page 42: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

29

Figure 4.7 Update Furniture Interface

Figure 4.7 shows, the staff can update the furniture details. The list of

information on the product will be shown. Staff can update the details of the

furniture that is chosen.

Page 43: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

30

4.2.1.5 Report

Figure 4.8 Booking Report Interface

Figure 4.9 Payment Report Interface

Figure 4.8 and figure 4.9 are the interfaces for staff to view the booking

and payment report that has been made by the customer. The details of the

report can be view when the staff click the today button or enter the specific

date to display it.

Page 44: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

31

.

Figure 4.10 Booking Report Interface

Figure 4.10 is the output interface for the list of booking details that

include customer details, furniture details, the status of payment, and booking

date.

Figure 4.11 Payment Report Interface

Figure 4.11 is the output interface for the list of payment details that

include customer details, booking dates, and a button to send a notification to

the customer.

Page 45: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

32

Customer 4.2.2

4.2.2.1 Register Interface

Figure 4.12 Customer Register

Figure 4.12 shows the customer register for Chatbot. Customer is

required to fill in their address, and phone number to before continue to the

next step.

Page 46: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

33

4.2.2.2 Menu Interfaces

Figure 4.13 Main Menu

Figure 4.14 List of product

Page 47: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

34

Figure 4.15 Details of the product

Figure 4.13, figure 4.14, and figure 4.15 are the interfaces for the

customer to view the list of products and the details of the product.

Page 48: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

35

4.2.2.3 Booking Interface

Figure 4.16 Ordering Product

Figure 4.17 Order Details

Figure 4.16 and figure 4.17 are the interfaces for the booking menu. It

shows the order process and the details of ordering.

Page 49: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

36

4.2.2.4 Payment Interfaces

Figure 4.18 Payment Details

Figure 4.19 Payment Process

Figure 4.18 and figure 4.19 are the interfaces for the payment. It shows

the payment details and the payment process .

Page 50: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

37

4.2.2.5 Update Address Interface

Figure 4.20 Update Address Process

Figure 4.20 is the interface for an address update. After the payment

process, the chatbot will notify the address for the product to be delivered. The

customer can update their new address if needed.

Page 51: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

38

Figure 4.21 Cancel Process

Figure 4.21 is the interface for the customer to cancel their order before

the payment process. They can cancel their order, as shown in the picture

above.

Page 52: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

39

4.3 Implementation

Test Cases 4.3.1

A test case can be defined as a condition for a tester to determine whether the

system, software, or the application build is working to their intended purpose of

building as it was originally functioning. The importance of the test case is it can help

to find out the problems that might happen on the function that makes a system not

working properly according to the system requirements. In a test case, it consists of a

component that describes an input, action, or event, and expected a response. All of

those are used to determine whether the system is working properly. The tables below

show the test cases for the several processes of the system.

Page 53: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

40

Test 4.3.2

4.3.2.1 Test Case Login

Table 4.1 Test Case for Login

Step Action Expected Response Pass / Fail Comment

1 Fill the “Staff

Id” field in the

login form

Validate the field. The

system will check

whether the Staff Id

input in form equal to

Staff Id in the

database.

If Staff Id in form

= Staff Id in the

database, it will

pass.

Proceed to

the next

field.

2 Fill “password”

field in the login

form

Validate the field. The

system will check

whether the password

input in the form

equal to the password

in the database.

If the password in

form = password

in the database, it

will pass.

An invalid

or empty

password

will not be

allowed

3 Click the

“Login” button

Login to homepage Pass Invalid

Staff Id

and

password,

the page

will

remain the

same

Pre-condition:

The staff must been registered so that their details already stored in database

Page 54: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

41

4.3.2.2 Test Case Add Furniture

Table 4.2 Test Case for Add Furniture

Step Action Expected Response Pass / Fail Comment

1 Click on “Add

New Stock”

Direct to add the

furniture page.

Pass -

2 Choose image

file

Validate the field. Pass The empty

field will not

be allowed

3 Select a

category

Validate the field. Pass The empty

field will not

be allowed

4 Field on

“Furniture Id”

field

Validate the field. Pass The empty

field will not

be allowed

5 Field on

“Furniture

Name” field

Validate the field. Pass The empty

field will not

be allowed

6 Field on “Price”

field

Validate the field. Pass The empty

field will not

be allowed

7 Field on

“Quantity” field

Validate the field. Pass The empty

field will not

be allowed

Pre-condition:

The staff must login into the system and must be on add furniture page

Page 55: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

42

Pre-condition:

The staff must login into the system and the furniture is in the database

4.3.2.3 Test Case Update Furniture

Table 4.3 Test Case for Update Furniture

Step Action Expected Response Pass / Fail Comment

1 Click update

button

Form page loaded Pass -

2 Enter the new

information

about the

furniture

- Pass -

3 Click on

“update” button

Message preview

successful

added or failure.

Redirecting

to list of furniture.

Pass -

Page 56: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

43

4.4 Feasibility Survey

A feasibility survey is a way to evaluate the project by testing it with real users.

It is a method used to evaluate how easy an application is to use. Therefore, feasibility

testing has been conducted in this project, and there is 36 responder that take part.

They are asked to test the chatbot without any help and guidance on how to use it.

After complete the test, they need to answer a question that been asked in a google

form. There are 9 questions for the user with the scale from Strongly Disagree(1) to

Strongly Agree(5) as shown in figure 4.22. The results of the survey shown question

2 and 6 is at the average level where a few of respondent find this system is complex,

and there is inconsistency in it. It can be seen the question 7 and 9 has the highest

level, which user think they can learn using this system very quickly and they feel

very confident to use it. Furthermore, the responses give good feedback about the

chatbot and they think it helps them throughout the purchase process to make

purchases more easily. Overall, this survey show how easy it is for users to use the

chatbot to reach their goals.

Page 57: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

44

Result for Feasibility Testing

Page 58: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

45

Page 59: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

46

Page 60: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

47

Figure 4.22 Result of Feasibility Survey

Page 61: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

48

CHAPTER 5

CONCLUSION

5.1 Introduction

This chapter discusses project contribution, project constraint, and its

development, future works that can be taken into consideration.

5.2 Project Contribution

This system is developed to help customers to make purchasing easier and

faster. Besides, it also assists the customer in knowing the details about the furniture

by helping them to save time. Instead of wasting time to visit the shop, they can save

their time by having a chat with a chatbot that contains all of the information about

furniture.

Page 62: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

49

5.3 Project Constraints and Limitation

There are limitations and constraints that occurred throughout the development

of this online chatbot. These problems and limitations in conducting this study are the

chatbots have a very limited dictionary where it is only able to understand a certain

question that has been asked by the user.

5.4 Future Works

In the future, there are still a lot of features that can be added to this system.

Here is some suggestion for the system to work more efficiently in the future. The

suggestions are:

For the chatbot, the system can auto recommend the new item to the customer.

For the payment process, the process will be directed to bank interfaces.

A chatbot can have a memory to save the last word from the user.

5.5 Conclusion

In conclusion, Furniture Online Ordering using Chatbot is suitable and relevant

as it can help customers to make purchasing easier and faster. Next, it also assists the

customer in knowing the details about the furniture by helping them to save time.

Furthermore, it helps the seller to enhance the relationship with the customer and help

them to promote their products, engage customers, and boost revenue.

Page 63: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

50

REFERENCES

[1] AbuShawar, B., & Atwell, E. (2015). ALICE chatbot: Trials and outputs.

Computación y Sistemas, 19(4), 625-632.

[2] Behera, B. (2016). Chappie-a semi-automatic intelligent chatbot. Write-Up.

[3] Yan, Z., Duan, N., Bao, J., Chen, P., Zhou, M., Li, Z., & Zhou, J. (2016).

Docchat: An information retrieval approach for chatbot engines using unstructured

documents. In Proceedings of the 54th Annual Meeting of the Association for

Computational Linguistics (Volume 1: Long Papers) (Vol. 1, pp. 516-525).

[4] Qiu, M., Li, F. L., Wang, S., Gao, X., Chen, Y., Zhao, W., ... & Chu, W.

(2017, July). Alime chat: A sequence to sequence and rerank based chatbot

engine. In Proceedings of the 55th Annual Meeting of the Association for

Computational Linguistics (Volume 2: Short Papers) (pp. 498-503).

[5]Serban, I. V., Sankar, C., Germain, M., Zhang, S., Lin, Z., Subramanian, S., ...

& Rajeswar, S. (2018). A deep reinforcement learning chatbot (Short Version).

arXiv preprint arXiv:1801.06700.

Page 64: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

51

APPENDIX

Page 65: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

52

APPENDIX A (GANTT CHART 1)

NO TASK WEEK

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

1 Topic Discussion and

Determination

2 Project Title Proposal

3 Proposal Writing -

Introduction

4 Proposal Writing -

Literature Review

5 Proposal Progress

Presentation &

Evaluation

6 Discussion &

Correction Proposal &

Proposed Solution

Methodology

7 Proposed Solution

Methodology

8 Proof of Concept

9 Drafting Report of the

Proposal

10 Submit draft of report

to supervisor

11 Preparation for Final

Presentation

12 Seminar Presentation

13 Final Report

Submission

Page 66: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

53

APPENDIX B (GANTT CHART 11)

NO TASK WEEK

01 02 03 04 05 06 07 08 09 10 11 12 13 14 15

1 Project Meeting with

Supervisor

2 Project Development

3 Progress Presentation

and Panel's Evaluation

4 Project Development

(continued)

5 Project Testing

6 Final Year Project

Format Writing

Workshop

7 Project Testing

(continued)

8 Submit Draft Report and

Documentation of the

Project

9 Preparation for Final

Presentation

10 Final Presentation and

Panel's Evaluation

11 Final Thesis Submission

and Supervisor's

Evaluation

Page 67: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

54

APPENDIX C ( CHATBOT CODING )

<?php

$servername="localhost";

$username="046608";

$password="12345";

$dbname="046608";

$conn=new mysqli($servername,$username,$password,$dbname);

if ($conn->connect_error) {

die("Connection_failed:". $conn->connect_error);

}

?>

<?php

$botToken = "890251091:AAFKmU4EbKzSc6LtGltkP552l5jzYmupzeE";

$website = "https://api.telegram.org/bot".$botToken;

//Grab the info from the webhook, parse it and put it into $message

$content = file_get_contents("php://input");

$update = json_decode($content, TRUE);

$message = $update["message"];

//Make some helpful variables

$chatId = $message["chat"]["id"];

$chatUsername = $message["chat"]["username"];

$chatFirstName = $message["chat"]["first_name"];

$chatLastName = $message["chat"]["last_name"];

$text = $message["text"];

Page 68: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

55

$photo=$message["photo"];

$input = strtolower($text);

$tarikh = date("Y-m-d");

if($chatId > 0){ // if bot talking to user

// ####### P r i v a t e R o o m #############

if(substr($text,0,6) === "Hi") {

$reply = "Hi there";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

}else if($text=="Salam"|| $text=="salam") {

$reply = "Waalaikumussalam..";

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

}else if(strpos($text,"hai") !== false || strpos($text,"Hai") !== false ||

strpos($text,"Hi") !== false|| strpos($text,"hi") !== false) {

$reply = "Hai there \xF0\x9F\x98\x8A";

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

} else if(strpos($text,"Thank") !== false || strpos($text,"tq") !== false) {

$reply = "Welcome \xF0\x9F\x98\x8A \xE2\x9D\xA4";

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing")

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

} else if(strpos($text,"How") !== false) {

$reply = "I am fine. Thank you for asking \xF0\x9F\x98\x8D";

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

Page 69: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

56

} else if($text=="time" || strpos($text,"date") !== false) {

$reply = "Today date and time: ".date("l jS \of F Y h:i:s A");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

}else if($text=="/start") {

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Assalamualaiku

m and Selamat Sejahtera\xF0\x9F\x98\x8A Welcome to Idaman Permaisuri Furniture

");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text= Before

proceeding to the next step, we need you to enter your address in the following format

:");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Example =

/address Blok B, Kolej Kediaman Unisza,Kampus Besut, 22200 Besut Terengganu");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

8C Make sure to put /address like the example");

}else if(strpos($text,"/address") !== false) {

$add=$text;

$alamat=str_replace("/address","",$add);

echo $alamat;

//buat checking

if (strlen($alamat)>=20){

$sql = "INSERT INTO customer(customer_id,Name,address)

VALUES ( '$chatId', '$chatFirstName', '$alamat' )";

$res = mysqli_query($conn, $sql);

while($row2 = mysqli_fetch_array($res))

{

$chatId = $message["chat"]["id"];

$chatFirstName = $message["chat"]["first_name"];

$alamat=$row2["alamat"];

Page 70: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

57

}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Next, please

enter your phone number in the following format :(example = /phonenumber

0139990315 )");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

8C Make sure to put /phonenumber like the example");

}else{

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing"

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=You enter the

invalid length of address");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text= Please enter

your address in the following format :");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Example =

/address Blok B, Kolej Kediaman Unisza,Kampus Besut, 22200 Besut Terengganu");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

8C Make sure to put /address like the example");

}

}else if(strpos($text,"/upaddress") !== false) {

$add=$text;

$alamat=str_replace("/upaddress"," ",$add);

echo $alamat;

if (strlen($alamat)>=20){

$sql = "UPDATE customer SET address='$alamat' WHERE

customer_id='$chatId'";

$res = mysqli_query($conn, $sql);

Page 71: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

58

while($row2 = mysqli_fetch_array($res))

{

$chatId = $message["chat"]["id"];

$chatFirstName = $message["chat"]["first_name"];

$alamat=$row2["alamat"];

}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=You address

have been successfully updated ");

$sql = "SELECT `address` FROM customer WHERE customer_id='$chatId' ";

$res = mysqli_query($conn, $sql);

$details = "";

while($row2 = mysqli_fetch_array($res))

{

$address=$row2["address"];

$details =$details." Your order will be delivered to this address :".$address."";

}

if ($res->num_rows > 0) {

$details = urlencode($details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x9A\x

9B".$details)

}

Page 72: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

59

{

$bt= "";

$b ="MENU";

$bb ="EXIT";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],' ;

$newbt=rtrim($bt,", ");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'],"one_time_keyboard":true}'; //

answerInlineQuery

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x91\x87 Click either to view our product or to Exit : ".$tastiera;

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}}else{

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing")

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=You enter the

invalid length of address");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text= Please enter

your address in the following format :");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Example =

/upaddress Blok B, Kolej Kediaman Unisza,Kampus Besut, 22200 Besut

Terengganu");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

8C Make sure to put /upaddress like the example");}

}else if(strpos($text,"/phonenumber") !== false) {

$phone=$text;

$number=str_replace("/phonenumber"," ",$phone);

echo $number;

if (strlen($number)>=10){

Page 73: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

60

$sql = "UPDATE customer SET phone_num='$number' WHERE

customer_id='$chatId'";

$res = mysqli_query($conn, $sql);

while($row2 = mysqli_fetch_array($res))

{

$text=$row2["phone_num"];

}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Thank You

for your registration.Now click on /Menu to proceed");

}else{

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=You enter the

invalid length of phone number");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Please enter

your phone number in the following format :(example = /phonenumber 0139990315

)");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

8C Make sure to put /phonenumber like the example");

}

} else if($text=="/menu" ||$text=="/MENU"|| $text=="/Menu" ||

strpos($text,"MENU") !== false){

$bt= "";

$b ="Table";

$bb ="Sofa";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],' ;

$newbt=rtrim($bt,", ");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'], "one_time_keyboard": true}'; //

answerInlineQuery

Page 74: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

61

$reply = "\xF0\x9F\x91\x87 Select which product that you like to view : ".$tastiera;

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}else if($text=="table" ||$text=="TABLE"|| $text=="Table") {

$sql = "SELECT * FROM furniture WHERE category='Table' AND quantity > '0' ";

$res = mysqli_query($conn, $sql);

$cate = " ";

$details = "";

while($row2 = mysqli_fetch_array($res)){

$c = $row2['furniture_id'];

$cn = $row2['name'];

$price= $row2['price'];

$img=$row2["fileToUpload"];

$details = $details."\n\nProduct : ".$cn."\nPrice:RM ".$price."";

$cate = $cate.'["P-'.$cn.'"],' ;

}

$details = urlencode($details);

$newcate=rtrim($cate," , ");

$tastiera = '&reply_markup={"keyboard":['.$newcate.'], "one_time_keyboard": true}';

// answerInlineQuery

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

Page 75: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

62

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Okay, so you

want to know about our Table product.");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Please wait a

second, i'll attach the list of our Table first, then you can select which product that you

want to view");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=

\xF0\x9F\x93\x9C List of Table :".$details);

$reply = "\xF0\x9F\x91\x86 Select which product you like, and tap on it :".$tastiera;

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}else if($text=="sofa" ||$text=="SOFA" || $text=="Sofa") {

$sql = "SELECT * FROM furniture WHERE category='Sofa' AND quantity > '0' ";

$res = mysqli_query($conn, $sql);

$cate = "";

$details = "";

while($row2 = mysqli_fetch_array($res))

{ $c = $row2['furniture_id'];

$cn = $row2['name'];

$price= $row2['price'];

$details = $details."\n\nProduct : ".$cn."\nPrice:RM ".$price."";

$cate = $cate.'["P-'.$cn.'"],' ;

}

$details = urlencode($details);

$newcate=rtrim($cate,", ");

$tastiera = '&reply_markup={"keyboard":['.$newcate.'], "one_time_keyboard": true}';

// answerInlineQuery

Page 76: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

63

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Okay, so you

want to know about our Sofa product.");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Please wait a

second, i'll attach the list of our Sofa first, then you can select which product that you

want to view");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x93\x

9C List of Sofa :".$details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x91\x86 Select which product you like, and tap on it : ".$tastiera;

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}else if(strpos($text,"-") !== false) {

$text=$text;

$perabot=str_replace("P-","",$text);

echo $perabot;

$sql = "SELECT * FROM furniture WHERE name='$perabot' ";

$res = mysqli_query($conn, $sql);

$cate = "";

$bt= "";

$details = "";

$b ="ORDER";

$bb ="EXIT";

$bc ="TABLE";

$bd ="SOFA";

$be ="PAYMENT";

while($row2 = mysqli_fetch_array($res))

{ $c = $row2['furniture_id'];

$cn = $row2['name'];

Page 77: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

64

$price= $row2['price'];

$img=$row2["fileToUpload"];

$quantity=$row2["quantity"];

$quantity=$row2["quantity"];

$details = $details."[Product Info of ".$perabot."]\n\n Product :

".$cn."\n Price:RM ".$price." \nQuantity In Stock: ".$quantity."\n\n";

$cate = $cate.'["'.$cn.'"],' ;

$bt = $bt.'["'.$b.'

'.$cn.'"],'.'["'.$bc.'"],'.'["'.$bd.'"],'.'["'.$be.'"],'.'["'.$bb.'"],' ; //jadi ada 3 button

}

$details = urlencode($details);

$newcate=rtrim($cate,", ");

$newbt=rtrim($bt,", ");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'], "one_time_keyboard": true}'; //

answerInlineQuery

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Okay, here are

the description of the product.");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=upload_phot

o");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=http://cloud.myf

ik.net/046608/perabot/Picture/$img");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x91\x87 Click either to make a Order,to go back to Table list and

Sofa list,to make a payment or to Exit :

".$tastiera;file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$re

ply);

Page 78: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

65

}else if(strpos($text,"ORDER") !== false) {

$text=$text;

$tempah=str_replace("ORDER ","",$text);

echo $tempah;

$date=date("Y-m-d");

$status="Belum Bayar";

$sql ="INSERT INTO booking(customer_id,furniture_id,name,price,date,status)

VALUES ('$chatId',(SELECT furniture_id FROM furniture WHERE

name='$tempah'),(SELECT name FROM furniture WHERE

name='$tempah'),(SELECT price FROM furniture WHERE

name='$tempah'),'$date','$status')";

$res = mysqli_query($conn, $sql);

while($row2 = mysqli_fetch_array($res)) {

$chatId=$value["message"]["chat"]["id"];

$furniture_id= $row2['furniture_id'];

$name= $row2['name'];

$price= $row2['price'];

$date=$row2["date"];}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Your Order has

been received");

$sql = "UPDATE furniture SET quantity=(quantity-1) WHERE name='$tempah'";

$res = mysqli_query($conn,$sql);

while($row2 = mysqli_fetch_array($res)) {

$text=$row2["quantity"];}

$date=date("Y-m-d");

$sql = "SELECT * FROM booking WHERE date='$date' AND name='$tempah' AND

status='Belum Bayar' ";

Page 79: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

66

$res = mysqli_query($conn, $sql);

details = "";

while($row2 = mysqli_fetch_array($res))

{ $c = $row2['furniture_id'];

$cn = $row2['name'];

$price= $row2['price'];

$date=$row2["date"];

$details = $details."Your Order:\n\nProduct Id : ".$c."\nProduct

Name: ".$cn." \n Price:RM ".$price."\n Date: ".$date."\n\n";

}

$details = urlencode($details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$details);

$bt= "";

$b ="PAYMENT";

$bb="MENU";

$bc ="EXIT";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],'.'["'.$bc.'"],' ;

$newbt=rtrim($bt,", ");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'], "one_time_keyboard": true}'; //

answerInlineQuery

$reply = "\xF0\x9F\x91\x87 Click either to make a Payment, to view Menu of our

product or to Exit : ".$tastiera;

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

Page 80: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

67

}else if(strpos($text,"CANCEL") !== false) {

$text=$text;

$batal=str_replace("CANCEL ","",$text);

echo $batal;

$sql ="DELETE FROM booking WHERE customer_id='$chatId' AND

name='$batal'";

if ($conn->query($sql) === TRUE) {

echo "Record deleted successfully";

} else {

echo "Error deleting record: " . $conn->error;

}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Your Order has

been cancel");

$sql = "UPDATE furniture SET quantity=(quantity+1) WHERE name='$batal'";

$res = mysqli_query($conn,$sql);

while($row2 = mysqli_fetch_array($res)) {

$text=$row2["quantity"];}

$bt= "";

$b ="PAYMENT";

$bb="MENU";

$bc ="EXIT";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],'.'["'.$bc.'"],' ;

$newbt=rtrim($bt,", ");

Page 81: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

68

$tastiera = '&reply_markup={"keyboard":['.$newbt.'], "one_time_keyboard": true}'; //

answerInlineQuery

$reply = "\xF0\x9F\x91\x87 Click either to make a Payment, to view Menu of our

product or to Exit : ".$tastiera;

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}else if($text=="PAYMENT"||$text=="Payment"||$text=="payment"){

$sql = "SELECT * FROM booking WHERE customer_id='$chatId' AND

status='Belum Bayar' ";

$res = mysqli_query($conn, $sql);

$details = "";

while($row2 = mysqli_fetch_array($res))

{ $c = $row2['furniture_id'];

$cn = $row2['name'];

$price= $row2['price'];

$date=$row2["date"];

$details =$details."\n\nProduct Id : ".$c."\n Product Name :

".$cn."\n Price:RM ".$price."\n Date:".$date."";

}

if ($res->num_rows > 0) {

$details = urlencode($details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=

\xF0\x9F\x93\x9C List of Order:".$details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply="\xF0\x9F\x91\x87 Please make your payment to this account\n\nBIMB :

130654565896\nName : Idaman Permaisuri";

Page 82: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

69

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x93\xB2 Please upload a picture of your receipt as a proof of your

payment.";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=To cancel your

order you need to enter the following format : CANCEL PRODUCTNAME");

}else{

$bt= "";

$bb="MENU";

$bc ="EXIT";

$bt = $bt.'["'.$bb.'"],'.'["'.$bc.'"],' ;

$newbt=rtrim($bt,", ");

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Your cart is

currently empty.");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'], "one_time_keyboard": true}'; //

answerInlineQuery

$reply = "\xF0\x9F\x91\x87 Click either to view Menu of our product or to Exit :

".$tastiera;

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}

}else if($photo) {

$sql = "SELECT * FROM booking WHERE customer_id='$chatId' AND

status='Belum Bayar' ";

Page 83: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

70

$res = mysqli_query($conn, $sql);

$details = "";

while($row2 = mysqli_fetch_array($res))

{ $c = $row2['furniture_id'];

$cn = $row2['name'];

$price= $row2['price'];

$date=$row2["date"];

}

if ($res->num_rows > 0) {

$file_id=$photo[1]['file_id'];

$img='https://api.telegram.org/bot' . $botToken .

'/getFile?file_id='.$file_id; //generate array file path

$gmbr= file_get_contents($img);

$gmbr= json_decode($gmbr, true);

$file_path=$gmbr['result']['file_path'];//display array file path

$url='https://api.telegram.org/file/bot'.$botToken.'/'.$file_path;

//generate url

function getimg($url) {

$headers[] = 'Accept: image/gif, image/x-bitmap, image/jpeg, image/pjpeg';

$headers[] = 'Connection: Keep-Alive';

$headers[] = 'Content-type: application/x-www-formurlencoded;charset=UTF-8';

$user_agent = 'php';

$process = curl_init($url);

curl_setopt($process, CURLOPT_HTTPHEADER, $headers);

curl_setopt($process, CURLOPT_HEADER, 0);

curl_setopt($process, CURLOPT_USERAGENT, $user_agent);

//check here

Page 84: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

71

curl_setopt($process, CURLOPT_TIMEOUT, 30);

curl_setopt($process, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1);

$return = curl_exec($process);

curl_close($process);

return $return;

}

$imgurl =$url;

$imagename= basename($imgurl);

if(file_exists('./receipt/'.$imagename)){

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=You

are not allow to enter the same image. Please enter the new receipt.");

return false;

}

$image = getimg($imgurl);

file_put_contents('receipt/'.$imagename,$image);

$date=date("Y-m-d");

$sql = "INSERT INTO payment( fileToUpload,customer_id,date)

VALUES ('$imagename', '$chatId', '$date' )";

$res = mysqli_query($conn, $sql);

while($row2 = mysqli_fetch_array($res))

{

$chatId=$value["message"]["chat"]["id"];

}

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

Page 85: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

72

$reply = "Thank you for your purchase, your order is being processed";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

$sql = "UPDATE booking SET status='Sudah Bayar' WHERE

customer_id='$chatId'";

$res = mysqli_query($conn, $sql);

while($row2 = mysqli_fetch_array($res))

{}

$sql = "SELECT `address` FROM customer WHERE customer_id='$chatId' ";

$res = mysqli_query($conn, $sql);

$details = "";

while($row2 = mysqli_fetch_array($res))

{

$address=$row2["address"];

$details =$details." Your order will be delivered to this address :".$address."";

}

if ($res->num_rows > 0) {

$details = urlencode($details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=\xF0\x9F\x9A\x

9B".$details);

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=If you want to

update your address please enter your address in the following format : Example =

/upaddress Unisza Kuala Terengganu");

}

Page 86: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

73

$bt= "";

$b ="MENU";

$bb ="EXIT";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],' ;

$newbt=rtrim($bt,", ");

$tastiera = '&reply_markup={"keyboard":['.$newbt.'],"one_time_keyboard":true}'; //

answerInlineQuery

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x91\x87 Click either to view our product or to Exit : ".$tastiera;

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}else{

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=Your cart is

currently empty. Please make a booking first");

$bt= "";

$b ="MENU";

$bb ="EXIT";

$bt = $bt.'["'.$b.'"],'.'["'.$bb.'"],' ;

$newbt=rtrim($bt,", ");

tastiera = '&reply_markup={"keyboard":['.$newbt.'],"one_time_keyboard":true}'; //

answerInlineQuery

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xF0\x9F\x91\x87 Click either to view our product or to Exit : ".$tastiera;

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".$reply);

}

Page 87: FURNITURE ONLINE ORDERING USING CHATBOT · Furniture Online Ordering using Chatbot was developed to helps entrepreneurs to get closer to customers. This chatbot may be able will help

74

}else if($text=="/help"){

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "\xE2\x9D\x93 Click the instructions below to use the instructions.\n\n

\xF0\x9F\x94\x8E /Menu- Menu of product\n \xF0\x9F\x93\x8D /Table-List of Table

\n \xF0\x9F\x93\x8D /Sofa-List of Sofa \n \xE2\x9E\xA1 /Exit";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

}else if($text=="EXIT" || strpos($text,"Exit") !== false){

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "You had cancelled your activity. Thank you for spending time with us.

\xF0\x9F\x98\x8A \xE2\x9D\xA4";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "Can you please do a little survey for us? Here is the link to the survey form

:";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply =

"https://docs.google.com/forms/d/e/1FAIpQLSdrH2a03k55OpGNXzfMXKKwcqc1A

1tZcCQ-Hs0Ufh2aNBXQww/viewform?usp=sf_link";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply));

} else {

file_get_contents($website."/sendchataction?chat_id=".$chatId."&action=typing");

$reply = "Sorry, but it seems like your words is out of my context \xF0\x9F\x98\xA5

Please read the instruction carefully \n Click /help to see the list of instructions.";

file_get_contents($website."/sendmessage?chat_id=".$chatId."&text=".urlencode($re

ply)); }

} else {// end of if bot chat to user