Twilio Samples - Register Trigger

<< Click to Display Table of Contents >>

Navigation:  Examples > Twilio Samples >

Twilio Samples - Register Trigger

Register
Account: Twilio SMS Receive From +447481347170
Message Source: Twilio
Checked Every:    On Demand

Trigger: Register

From Address:
*
Subject Contains:
register

Responds to 'Register' SMS being sent. Asks the customer for their Name, Company & Email and stores the information in a database. Once registered the customer can send other SMS commands.

Extracted Fields

From Look For: "FROM" Then Look For: ":" Extract Until: Until End Of Line
Body Look For: "BODY" Then Look For: ":" Extract Until: Until End Of Line
ToCountry Look For: "TOCOUNTRY" Then Look For: ":" Extract Until: Until End Of Line
Status Look For: "SMSSTATUS" Then Look For: ":" Extract Until: Until End Of Line
FromCountry Look For: "FROMCOUNTRY" Then Look For: ":" Extract Until: Until End Of Line
ToNumber Look For: "TO" Then Look For: ":" Extract Until: Until End Of Line

Actions

Send Popup Message %AccountName% Register Started
Set Variable Newsletter = Y
Set Variable Name =
Set Variable Email =
Set Variable FirstName =
Set Variable CompanyName =
Update A Database %PSLCentral%
// Check if already exists
Lookup From A Database SELECT * FROM [PSLCentralTemp].[dbo].[ThinkAutomationSMSDemoRegistrations] WHERE FromNumber = '%From%'
If  %CompanyName% Not Blank  Then 
Twilio Send SMS Message  To %From% "Your phone number is already registered to %CustomerName%"
End Processing
End If
// Ask For Name
Twilio Send SMS Message  To %From% "Thank you for registering with Parker Software. Could you tell me your Name?" (Assign Status To %Status%)
If  %Status% <> delivered Then End Processing
Twilio Wait For SMS Reply  From Last Sent Wait For 240 Seconds (Assign Message Text To %Name%)
If  %Name% Is Blank  Or Len(%Name%) >  250 Then 
Twilio Send SMS Message  To %From% "I didnt receive a valid response. Please start over." (Assign Status To %Status%)
End Processing
End If
Set Variable Name = %Name% (Trim Blanks)
Set Variable Name = %Name% (Word Capitalize)
Set Variable FirstName = %Name% (Extract First Word)
// Ask For Company Name
Twilio Send SMS Message  To %From% "And your Company Name %FirstName%?" (Assign Status To %Status%)
If  %Status% <> delivered Then End Processing
Twilio Wait For SMS Reply  From Last Sent Wait For 240 Seconds (Assign Message Text To %CompanyName%)
If  %CompanyName% Is Blank  Or Len(%CompanyName%) >  250 Then 
Twilio Send SMS Message  To %From% "I didnt receive a valid response. Please start over." (Assign Status To %Status%)
End Processing
End If
Set Variable CompanyName = %CompanyName% (Trim Blanks)
Set Variable CompanyName = %CompanyName% (Word Capitalize)
// Ask For Email
Twilio Send SMS Message  To %From% "And Email Address?" (Assign Status To %Status%)
If  %Status% <> delivered Then End Processing
Twilio Wait For SMS Reply  From Last Sent Wait For 240 Seconds (Assign Message Text To %Email%)
If  %Email% Is Not A Valid Email Address  Or Len(%Email%) >  250 Then 
Twilio Send SMS Message  To %From% "This is not a valid email address. Please start over." (Assign Status To %Status%)
End Processing
End If
Set Variable Email = %Email% (Convert To Lower Case)
// Newsletter
Twilio Send SMS Message  To %From% "Would you like to sign up to our newsletter? Please send Y or N" (Assign Status To %Status%)
If  %Status% <> delivered Then End Processing
Twilio Wait For SMS Reply  From Last Sent Wait For 120 Seconds (Assign Message Text To %Newsletter%)
Set Variable Newsletter = %Newsletter% (Convert To Upper Case)
If  %Newsletter% <> Y And %Newsletter% <> N Then 
Select Case %Newsletter%
Case = YES
Set Variable Newsletter = Y
Case = NO
Set Variable Newsletter = N
Case  Else
Set Variable Newsletter = N
End Select
End If
// Done - Update Database
Update A Database Using Custom SQL %PSLCentral%
Select Case %FromCountry%
Case = GB
Set Variable MainOfficeNumber = 0330 0882 943
Case = US
Set Variable MainOfficeNumber = (800) 680 7712
Case  Else
Set Variable MainOfficeNumber = +44 1782 822577
End Select
Twilio Send SMS Message  To %From% "You have been successfully registered with: Name: %Name% Company: %CompanyName% Email: %Email% Telephone: %From%" (Assign Status To %Status%)
Send An Email  To %Email% "Parker Software ThinkAutomation Demo SMS Account Created"
Send Popup Message %AccountName% Register Completed
End Of Actions

Sample Incoming Message

Subject: Register

FROM: +447798646913
BODY: Register

TOCOUNTRY: GB
SMSMESSAGESID: SM067d850315e351c8336ffb92fa89a675
NUMMEDIA: 0
SMSSID: SM067d850315e351c8336ffb92fa89a675
SMSSTATUS: received
FROMCOUNTRY: GB
TO: +447481347170
NUMSEGMENTS: 1
MESSAGESID: SM067d850315e351c8336ffb92fa89a675
ACCOUNTSID: ACf4a09fc9048473636db653aa6b2ba439
HTTP_USER_AGENT: TwilioProxy/1.1
HTTP_X_TWILIO_SIGNATURE: fJJTV4TAMpG9GYVLAPR6FaK5Rck=
 
ThinkAutomation © Parker Software 2016