How to Update Contact Information through Named Pipe
This sample demonstrates how to use the named pipe of the Info service to
update contact information.
File
UpdateContact.vbs used in this sample is located in the folder:
C:\Program Files\CodeSegment\SMS Studio\Samples\InfoService
Upon receiving an incoming message, the script
UpdateContact.vbs updates the contact's name, adds the contact into a
predefined group and sends back an appropriate reply to the contact.
The contents of the UpdateContact.vbs file:
if WScript.Arguments.Count = 5 then
PipeName = WScript.Arguments(0)
MsgID = WScript.Arguments(1)
ContactPhone = WScript.Arguments(2)
ContactName = WScript.Arguments(3)
ContactGroup = WScript.Arguments(4)
if PipeName <> "" then
set fso = CreateObject("Scripting.FileSystemObject")
set pipe = fso.CreateTextFile("\\.\pipe\" & PipeName)
pipe.WriteLine("Contact: " & ContactPhone)
pipe.WriteLine("Name: " & ContactName)
pipe.WriteLine("AddGroup: " & ContactGroup)
pipe.WriteLine("<Update>")
pipe.WriteLine("ReplyToID: " & MsgID)
pipe.WriteLine("Text: Thanks for updating your name.")
pipe.WriteLine("<Send>")
pipe.Close
WScript.Quit(0)
else
MsgBox "Error: Pipe name is missing.", vbCritical, "SMS Studio Update Contact Sample"
WScript.Quit(1)
end if
else
MsgBox "Error: Wrong number of arguments.", vbCritical, "SMS Studio Update Contact Sample"
WScript.Quit(1)
end if
How to run this sample
- Click the New button on the main toolbar and select the Info service option in the New Service dialog.
- Click the Setup button on the main toolbar to display the Info Setup dialog.
- In the General tab of the Info Setup dialog click the Add button to display the Add Rule dialog.
- In the General tab of the Add Rule dialog enter the following parameters:
Name: Update Contact
Pattern: Name *
Action: Execute external application
- In the Execute tab of the Add Rule dialog enter the following parameters:
External application: UpdateContact.vbs - use the selection button ( ... ) to locate and select the external application.
Application parameters:
"%PipeName%" "%MsgID%" "%MsgFromPhone%" "%P%"
"FRIENDS"
- Click the Add button to close the Add Rule dialog.
- In the Advanced tab of the Info Setup dialog enter the name of the pipe:
Pipe name: UpdatePipe
- Click the OK button to close the Info Setup dialog.
- Click the Start
button on the main toolbar to start the Info service.
- Use Tools / Receive Message option in the main menu to
display the Receive Message dialog. Fill in the Phone and
Text fields (e.g. +123456 and Name John) and click the Receive
button. The Info
service will receive this message and run the UpdateContact.vbs
application which will update the contact's name, add him to the group FRIENDS, and send back a reply which will be
placed in the Outbox.
Related topics
Named Pipe