メニュー

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

TwiML™ Voice: <Prompt>

The TwiML's <Pay> Verb's <Prompt> noun allows you to customize the default prompts used by <Pay>.

For example, by default when asking a user to input a credit card number <Pay> will say "Please enter your 15 to 16 digit credit card number". You can override that to "Please enter your 15 digit Visa or Mastercard number" with the following TwiML:

        
        
        
        
        Ask for a user's credit card number.

        Prompt for card number

        Ask for a user's credit card number.

        Or use the following TwiML to replace Text-to-Speech with a pre-recorded audio file:

              
              
              
              
              Ask for a user's credit card number through a recorded MP3.

              Prompt for card number with MP3

              Ask for a user's credit card number through a recorded MP3.

              <Prompt> Attributes

              The following attributes on <Prompt> allow you to customize the messages played by <Pay>:

              属性名 許容値 Default Values
              for payment-card-number, expiration-date, security-code, postal-code , payment-processing none, required.
              errorType timeout, invalid-card-number, invalid-card-type, invalid-date, date-validation-failed, invalid-security-code None. Multiple values can be provided space separated.
              cardType visa, master-card, amex, maestro, discover, optima, jcb, diners-club, enroute none, optional. Multiple values can be provided space separated.
              attempt 1 to 10 Multiple values can be provided space separated. See examples.

              for

              The following are possible values of for:

              for 概要
              payment-card-number Use to customize messages played for asking for credit or debit card information.
              expiration-date Use to customize messages played for asking for expiration date.
              security-code Use to customize messages played for asking for security code (CVV).
              postal-code Use to customize messages played for asking for postal code.
              payment-processing Use to customize messages played before processing the payment.

              errorType

              The following are possible values of errorType:

              errorType 概要
              Timeout <Pay> received a timeout when executing a specific Step.
              invalid-card-number <Pay> didn’t receive the appropriate number of digits for either credit card number, expiration date, security code or zip code. Or card number entered didn’t pass the validation. This reason can be used to apply further customization on the message to play such as informing payee/caller that the incorrect number of digits were entered.
              invalid-card-type The card number entered didn’t match the accepted card types. For example, if only visa or master-card are accepted and payee enters amex, InvalidReason parameter will contain this value.
              invalid-date <Pay> didn’t receive the correct number of digits for the date.
              date-validation-failed The expiration date entered was in the past or incorrect.
              invalid-security-code This reason is generated when the payee entered an invalid security code. For example, if Credit Card number is amex and user entered 3 digits for the security code.
              invalid-postal-code <Pay> didn’t receive the correct number of digits for the postal/zip code

              cardType

              The cardType attribute allows you to override <Prompt> for specific credit card types.

              This is useful to customize the prompt when asking for a security code, as different cards handle security codes differently. For example, the following TwiML says a custom message if the credit card number provided by the caller was a Visa card:

                    
                    
                    
                    
                    Ask for the 3 digit Visa security code.

                    Prompt for a Visa security code

                    Ask for the 3 digit Visa security code.

                    The following TwiML says a custom message if the caller provided an American Express credit card number:

                          
                          
                          
                          
                          Ask for the 4 digit American Express security code.

                          Prompt for an American Express security code

                          Ask for the 4 digit American Express security code.

                          attempt

                          The Attempt attribute allows you to customize prompts for differents attempts within <Pay>.

                          The following TwiML says different message when asking for expiration date the first time Vs the 2nd or 3rd attempt in case the user timedout.

                                
                                
                                
                                
                                Add an alternate response if there is an error the first time through a prompt attempt.

                                Change message on repeated attempts

                                Add an alternate response if there is an error the first time through a prompt attempt.

                                The following examples show the TwiML you can use to customize all prompts for <Pay>:

                                 <Prompt for="payment-card-number">
                                   <Say voice="Polly.Joanna">
                                      Please enter your credit card number.
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="payment-card-number" errorType="timeout">
                                   <Say>
                                      I am sorry I didn’t hear anything. Please enter your credit card number.
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="payment-card-number" errorType="invalid-card-number">
                                   <Say>
                                      That was an invalid card number. Please try again
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="payment-card-number" errorType="invalid-card-type">
                                   <Say>
                                      That was an invalid card type, please try again. We only accept Insert accepted card types.
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="expiration-date">
                                   <Say>
                                      Please enter your expiration date, two digits for the month and two digits for the year.
                                   </Say>   
                                 </Prompt>
                                 
                                 <Prompt for="expiration-date" errorType="timeout">
                                   <Say>
                                      I am sorry I did not hear anything. Please enter your expiration date, two digits for the month and two digits for the year. For example, to enter July twenty twenty two, enter 0 7 2 2.
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="expiration-date" errorType="invalid-date">
                                   <Say>
                                      That is an invalid date. Please enter your expiration date, two digits for the month and two digits for the year. For example, to enter July twenty twenty two, enter 0 7 2 2.
                                   </Say>
                                 </Prompt>
                                 
                                 <Prompt for="expiration-date" errorType="date-validation-failed">
                                   <Say>
                                      That is an invalid date, expiration date cannot be past date. Please try again.
                                   </Say>
                                 </Prompt>
                                 
                                <!-- If the credit card number type provided only requires 3 digit security code use the following -->
                                  <Prompt for="security-code">
                                    <Say>
                                       Please enter your security code. It’s the 3 digits located in the back of your card.
                                    </Say>   
                                  </Prompt>
                                
                                <!-- If the credit card number type provided requires 4 digit security code use the following-->
                                  <Prompt for="security-code" cardType="Amex">
                                    <Say>
                                       Please enter your security code. It’s the 4 digits located in the front of your card.
                                    </Say>   
                                  </Prompt>
                                
                                <!-- If the credit card number type provided requires 4 digit security code use the following-->
                                  <Prompt for="security-code" errorType="timeout">
                                    <Say>
                                       I am sorry I didn’t hear anything. Please enter your security code. It’s the 4 digits located in the front of your card.
                                    </Say>
                                  </Prompt>
                                
                                <!-- If the credit card number type provided only requires 3 digit security code use the following-->
                                  <Prompt for="security-code" errorType="timeout">
                                    <Say>
                                       I am sorry I didn’t hear anything. Please enter your security code. It’s the 3 digits located in the back of your card.
                                    </Say>
                                  </Prompt>
                                
                                <!-- If the Payee supposed to enter 3 digits but entered either less or greater than 3 digits -->
                                  <Prompt for="security-code" errorType="invalid-security-code">
                                    <Say>
                                      That was an invalid security code. The security code must be 3 digits. Please try again
                                    </Say>
                                  </Prompt>
                                
                                <!-- If the Payee supposed to enter 4 digits but entered either less or greater than 4 digits -->
                                  <Prompt for="security-code" errorType="invalid-security-code">
                                    <Say>
                                      That was an invalid security code. The security code must be 4 digits. Please try again
                                    </Say>
                                  </Prompt>
                                
                                  <Prompt for="postal-code">
                                    <Say>
                                       Please enter your 5 digit billing zip code.
                                    </Say>
                                  </Prompt>
                                
                                  <Prompt for="postal-code" errorType="timeout">
                                    <Say>
                                       I am sorry I didn’t hear anything. Please enter your 5 digit billing zip code.
                                    </Say>
                                  </Prompt>
                                
                                  <Prompt for="postal-code" errorType="invalid-postal-code">
                                    <Say>
                                      That was an invalid billing zip code. The billing zip code must be 5 digits. Please try again
                                    </Say>
                                  </Prompt>
                                
                                  <Prompt for="payment-processing">
                                    <Say>
                                      Thank you, please wait while we process your payment
                                    </Say>   
                                  </Prompt>
                                </Pay>
                                </Response>
                                
                                Rate this page:

                                ヘルプが必要ですか?

                                誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。