Scenario: Guessing Game

From $1

    Doc-Wiki-BannerHK.png

    (Click the banner to go to the related Docs.Code.ExactTarget.com page.)

    Overview

    A radio station runs a promotion where listeners must discover a password to win a t-shirt. To discover the password, the listeners must guess the correct number between 1 and 100. The listeners text GUESS and a guess to the radio station's short code. For example, to guess 50, a listener texts in GUESS 50. If the guess is too low or high, the system responds with an SMS message saying to guess a higher or lower number. If the guess is correct, the listener receives the password to redeem for a station t-shirt.

    To make this scenario work, the radio station must:

    • Create a data extension called GUESSDE to contain the guessing conversations
    • Write the AMPscript to send the correct response
    • Create an SMS MO Keyword to respond to the listeners' MO messages

    Creating the Data Extensions

    The GUESSDE data extension stores the phone number and guess for the listeners who enter the contest. When a listener sends an SMS message with a guess, a row is created in this data extension.

    SMSradio1_DE.png

    Creating the AMPscript

    This block of AMPscript creates a row in the GUESSDE data extension with the listener's phone number and guess if the incoming message starts with the word GUESS. After the first message, the listener does not include the verb, so the previous conversation continues.

    After starting the conversation, the AMPscript block selects a random number between 1 and 100 that the listener is trying to guess. The code compares the guess with the random number:

    • If the guess is higher than the random number, the listener receives an SMS that says: Nice try but [the guess] is too high...Why not give it another shot?
    • If the guess is lower than the random number, the listener receives: Nice try but [the guess] is too low...Why not give it another shot?
    • If the guess is correct, the listener receives: You guessed it! Call the station and say "94.3 Rocks My Midday" for your t-shirt.
    • If the guess is less than 1 or more than 100, the listener receives: That's an invalid guess.  Try again!
    %%[
    VAR @Number
    IF UPPERCASE([MSG(0).VERB]) == "GUESS" THEN
         /* Reset game */
         SET @Number = RANDOM(1, 100)
         UPSERTDATA("GUESSDE", 1, "Phone", MOBILE_NUMBER, "Number", @Number)
         SetSmsConversationNextKeyword("12345", MOBILE_NUMBER, "GUESS")
         ]%%Starting new game!  Guess a number from 1 to 100!%%[
    ELSE
         VAR @Guess
         SET @Guess = V([MSG(0).VERB])
         IF @Guess <= 100 AND @Guess >= 1 THEN
              VAR @Number
              SET @Number = LOOKUP("GUESSDE", "Number", "Phone", MOBILE_NUMBER)
      
              IF @Number == @Guess THEN
                   ]%%You guessed it! Call the station and say "94.3 Rocks My Midday" for your t-shirt.%%[
              ELSE
                   IF @Number < @Guess THEN
                        ]%%Nice try but %%=V(@Guess)=%% is too high... Why not give it another shot?%%[
                   ELSE
                        ]%%Nice try but %%=V(@Guess)=%% is too low... Why not give it another shot?%%[
                   ENDIF
                   SetSmsConversationNextKeyword("12345", MOBILE_NUMBER, "GUESS")
              ENDIF
         ELSE
              ]%%That's an invalid guess.  Try again!%%[
              SetSmsConversationNextKeyword("12345", MOBILE_NUMBER, "GUESS")
         ENDIF
    ENDIF
    ]%%

     Creating the SMS MO Keyword

    The radio station creates an SMS MO keyword and includes the above AMPscript block in the Message field. As soon as the radio station saves this keyword, listeners can begin submitting guesses to play the game.

    SMSradio2_MO.PNG


    This page was last updated by Ryan Williams on Fri, 06 Jan 2012 21:24:22 GMT.

    If you require assistance with the ExactTarget application, please contact Global Support. If you wish to send Ryan direct feedback, fill out the form below:

     


    Was This Page Helpful?
    Suggestions or Comments:
    Name (optional):
    Email Address (optional):
    Enter 25380 backwards:
       
    Tags: (Edit tags)
    • No tags
    FileSizeDateAttached by 
    SMSradio1_DE.png
    No description
    19.73 kB17:24, 6 Jan 2012AdminActions
    SMSradio2_MO.PNG
    No description
    19.11 kB17:24, 6 Jan 2012AdminActions
    Comments (0)
    You must login to post a comment.

     
    Powered by MindTouch 2010
    Admin