# Design and Implementation of a Smart Intercom System through Web Services on Web of Things
## 5 Implementation
### System Implementation and Results  
The standby screen of the system is shown in Figure 12a. When the visitor presses the floor number button, the system finds the user ID according to the floor number, runs the program of this system, and sends the system message to the resident's smartphone through messaging API. Then, the system activates the camera to take a picture of the visitor, and the image is displayed on the system screen, as shown in Figure 12b.  
After the visitor presses the make photo button, the system uploads the photo to the image hosting service website. It then notifies the chatbot server to run the program to obtain the visitor's photo and to send it to the resident according to the image URL.  
The resident receives a photo of the visitor, as shown in Figure 13, and then decides whether to open the door. The resident can click on one of the \"Open Door\", \"Watch\", \"Alarm\", and \"Busy\" menus on the instant messaging software. After the resident presses any of the buttons, the instant messaging platform will execute the program code that is mapped to the message.  
The system has two separate channels in the implementation, each with a webhook URL corresponding to the chatbot function. The push function is a system that sends messages to the resident after the visitor presses the floor number. The callback function is used after the resident sends a message by the chatbot server to control a door lock, buzzer, or related device.  
When the instant messaging platform receives messages from residents who want to control door locks, buzzers, or related devices, it executes different messaging APIs based on different event messages. These messages are passed to the chatbot server of the embedded system through a webhook service that can determine the object and type of various messages and execute the codes to control each pin circuit of the embedded system to achieve the purpose of the set execution function.  
The resident clicks the \"Open\" button when the instant messaging software sends a text message to the messaging API. The text message is then transmitted to the chatbot server through the instant messaging platform, and the event is triggered to execute a specific function according to the message. The system will give high power to the GPIO 4 pin to allow the relay to energize. The relay will trigger the door lock to open and then automatically disconnect after 5 s, and then, the door can be locked automatically, as shown in Figure 14.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Method** & **Sender** & **Receiver** & **Sending Method** \\ \hline Reply & Bot & Sent message user & Chatbot passively replies to user messages \\ Push & Bot & Specific users or groups & Chatbot proactive push \\ \hline \hline \end{tabular}
\end{table}
Table 3: Two ways to send messages on instant messaging platforms.  
Figure 12: (a) The standby screen of the system. (b) The camera to take a picture.  
When a resident clicks the \"Alarm\" button, the instant messaging software uses messaging API to send a text message through the messaging platform to the chatbot server to trigger an alert event and perform specific program functions based on the message. This alert event will control the GPIO 21-pin high power to activate the buzzer for 5 s, as shown in Figure 15.