| |
 |
| |
Build an SMS Directory Bot in just 4 hrs (including testing) |
 |
This tutorial demostrates how it is possible to build an SMS Directory Bot in just 4 hrs (including testing) using the VisualGSM Application Server platform with a good knowledge of a web scripting language like Active Server Page (ASP). The bot searches an online directory and returns the result to the user via SMS.
Warning: This is only a hypothetical example created for a user demo, the site described in the example may not work at this point in time.
|
 |
| Note: You can download a 45-days evaluation for VisualGSM Enterprise from http://www.visualtron.com/download.htm. |
| |
| Introduction |
| In this example, we build sample codes to post search enquiries to the web server, extract the post results, and SMS them to the user. As each SMS can take only a maximum of 160 characters we need to split the search sequence into 2 steps, although the actual web search is a single step. The first search will return a maximum of 5 results, displaying only a 1-5 serial number followed by the names searched. For purpose of ease of use, we restrict to only up to 5 results, so users have to be more precise in their search critieria to minimize the number of search results returned. |
 |
| e.g. a search of "John", reveals: |
 |
| For example, the user sends "find John", case insensitive, to VisualGSM Enterprise. For our demo, the number is +6593677274 (note, to access, your mobile network must have roaming agreement with Singapore's MobileOne). |
 |
| The results are - |
 |
1. CHIA Yeong Jia, John
2. John ONG
3. John ONG
4. John TAN Wei Siang
5. ONG Cho Whatt, John |
 |
The next step is to refine the search and indicate which person's information is required. The user chooses e.g. John TAN Wei Siang. He sends " 4 " as a reply. The server response with contact details. |
 |
John TAN Wei Siang Assistant Manager (Corporate Planning) 8389340 tan_wei_siang@mcds.gov.sg MINISTRY OF COMMUNITY DEVELOPMENT AND SPORTS |
| |
| DEVELOPMENT / SETUP WEB SERVER |
| So how do we build such an application which can handle hundreds of users at the same time? |
 |
| VisualGSM Enterprise does it by providing a web-sms gateway platform, in which the developer can develop Active Server Page scripts on a matured multi-threaded application web server like the Internet Information Server (IIS). (We use ASP as an example here, most types of web scripts, dlls, servlets, and CGIs are supported by VisualGSM Enterprise. If Apache is to be used, you would want to convert the ASP scripts in this example to PHP). |
 |
| SCRIPTING - The developer builds along the lines of a web application, and in this case, the script response to VisualGSM Enterprise instead of a user's web browser. VisualGSM Enterprise acts as a middleware and response to the user via SMS. Messages received from the user are converted to HTTP GET requests to passed to a pre-designated script. The script used will depend on the message sent. |
 |
| For the sample project, there are 2 scripts, search.asp, and retrieve.asp. |
 |
| Search.asp, is the first step mentioned above, and serves to post the search phrase, extract the names searched, execute a http response, and store the detailed results in a database table by user number. Retrieve.asp will read from the database the name selected, and response the details to VisualGSM Enterprise, which then translates the result to SMS. |
 |
Download search.asp Download retrieve.asp |
 |
| HTTP COMPONENT - We use a free component, ASPtear to post and extract the search results. You need to download asptear.dll from http://www.alphasierrapapa.com/IisDev/Downloads/AspTear.zip Copy asptear to the system32 folder of the IIS machine and register by issuing the command "regsvr32 asptear.dll". |
 |
| SQL TABLE Setup - We create a table MITADEMO_LOG to temporarily store searched details extracted by search.asp. Retrieve.asp will then retrieve from this table. You can use the default VisualGSM Enterprise database or any other SQL type of database, e.g. Microsoft SQL Server, Oracle, etc. |
 |
CREATE TABLE "MITADEMO_LOG" ( "ID" Integer NOT NULL, "CONTENT" Varchar (255) NOT NULL, "MOBILENUM" Varchar (30) NOT NULL ) |
 |
| Remember to create a DSN for this database table. If you are using the default database for VisualGSM Enterprise, the DSN is VisualGSMODBC, and server is the machine running the database. |
| |
| CONFIGURING VISUALGSM ENTERPRISE |
| Configure a set of keyword as shown in the screen capture. Note that you need to edit the URL and point it to the location of your scripts, which most probably is different from the example shown below. Keyword F and F1 are spelling variations of FIND, and all are related to the same asp script. "NOKEYWORD" keyword is a catch all situation whereby an instruction on the correct message format "Please send a Find..." is sent to the user. "HELP" and "NOKEYWORD" keyword use the keyword type "INFO". The other keyword use type "HTTP URL". |
 |
| Once done, you are ready to test your application:- |
 |
 |
 |
 |
| |
| OFFLINE TESTING |
| You can test your application without actually sending any SMS using VisualGSM Enterprise's Test command. This can be done by creating parameter values and then using the Test command to POST to the web server. |
 |
| For example, in the screen capture below, we assign the search string "John" and the user's mobile "96550202" under the keyword "FIND" to post parameters of "MSG" and "ORIG" respectively to search.asp. Note that MSG = {M}, and ORIG ={N}, where {M} is the message less the keyword, and {N} is the sender's mobile number. On Test command, a browser windows will popout and return 5 results with the search string "John". |
 |
 |
 |
 |
 |
| The same applies for keyword 1 to 5. In these cases, the KEYWORD parameter is assigned to their respective 1 to 5. Note that KEYWORD, ORIG, and MSG are default parameters passed to the script assigned. They are present in every HTTP URL action. For additional parameters, they have to be defined separately in "Parameter" field. |
 |
| The ability to test test offline improves productivity by 50% to 200%. Once you are comfortable with the stability of the system, you can test using your mobile phones as a final step. |
| |
 |
| |
| Troubleshooting |
 |
If you are facing any issues, please refer to the sms_server_log.txt file for logging details.
Default path for sms server log:
c:\Program Files\Visualtron Software Corporation\VisualGSM\vgsmlog\sms_server_log.txt
If you have any questions or comments, you may post on the support forum for this tutorial - click here. |
| |
 |
| |
| Relevant links |
How to configure VisualGSM to conduct a survey, and store the survey results in a database, in just 15 minutes Java Examples to Send SMS, Receive SMS.
|
| |
| |
| |