Created
December 11, 2019 00:50
-
-
Save Xabadu/7127ef1318885401f892049dd54ee275 to your computer and use it in GitHub Desktop.
Twilio Studio flow to capture payments using Twilio Pay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"description": "A New Flow", | |
"states": [ | |
{ | |
"name": "Trigger", | |
"type": "InitialState", | |
"properties": { | |
"offset": { | |
"x": 0, | |
"y": 0 | |
}, | |
"flow_url": "https://webhooks.twilio.com/v1/Accounts/AC2335a74ad5fd08ca1030e3d53e1f7ff9/Flows/FWf6cc617da37899eac768f69e50df2e88" | |
}, | |
"transitions": [ | |
{ | |
"event": "incomingMessage", | |
"conditions": [], | |
"next": null, | |
"uuid": "a594a2f0-82e3-4485-91e4-d505c256578b" | |
}, | |
{ | |
"event": "incomingCall", | |
"conditions": [], | |
"next": "FF850b19fc7238315001ddee9da3fed292", | |
"uuid": "8131ff83-97cd-4e40-9c78-eb2f6175afbc" | |
}, | |
{ | |
"event": "incomingRequest", | |
"conditions": [], | |
"next": null, | |
"uuid": "040b5737-ebd5-472a-9520-e7917cd291e2" | |
} | |
], | |
"sid": "FF0534f6ad55babd1a9204102dcc5d2479" | |
}, | |
{ | |
"name": "collectDonation", | |
"type": "Pay", | |
"properties": { | |
"offset": { | |
"x": -80, | |
"y": 690 | |
}, | |
"timeout": 5, | |
"max_attempts": 2, | |
"security_code": true, | |
"postal_code": "false", | |
"payment_connector": "default", | |
"payment_token_type": "reusable", | |
"payment_amount": "{{flow.variables.amount}}", | |
"currency": "usd", | |
"description": null, | |
"valid_card_types": [], | |
"language": "en-US", | |
"min_postal_code_length": null, | |
"payment_method": null, | |
"bank_account_type": null, | |
"parameters": null | |
}, | |
"transitions": [ | |
{ | |
"event": "success", | |
"conditions": [], | |
"next": "FF64b837e6fd18a621439846372f4e83f0", | |
"uuid": "128daa98-e3ae-4b77-8787-dd28261dd80f" | |
}, | |
{ | |
"event": "maxFailedAttempts", | |
"conditions": [], | |
"next": null, | |
"uuid": "42efd700-4e0e-41ff-b9ed-1b5f7708e1ae" | |
}, | |
{ | |
"event": "providerError", | |
"conditions": [], | |
"next": "FF7115346f1f14b95f7586a2bc219d51c8", | |
"uuid": "b597ac55-aeb9-4ef5-9aef-5fc21b30d99c" | |
}, | |
{ | |
"event": "payInterrupted", | |
"conditions": [], | |
"next": null, | |
"uuid": "81da33ae-74ad-42a5-9f74-f84692791fd1" | |
}, | |
{ | |
"event": "hangup", | |
"conditions": [], | |
"next": null, | |
"uuid": "b4883a96-3e0c-41c8-a25b-59b33de74863" | |
}, | |
{ | |
"event": "validationError", | |
"conditions": [], | |
"next": "FF382b6a08549a6faa66e8ac6dac7ae89b", | |
"uuid": "0f52a126-2e33-4560-a062-89512db9afa5" | |
} | |
], | |
"sid": "FF521b039652f148adfe354169826b9628" | |
}, | |
{ | |
"name": "welcomeMessage", | |
"type": "SayPlay", | |
"properties": { | |
"offset": { | |
"x": -74, | |
"y": 177 | |
}, | |
"say": "Welcome to the donation system", | |
"play": null, | |
"voice": "alice", | |
"language": "en-US", | |
"loop": 1, | |
"digits": null | |
}, | |
"transitions": [ | |
{ | |
"event": "audioComplete", | |
"conditions": [], | |
"next": "FF929ed07da7d5321cc764b5aff30228ea", | |
"uuid": "817ca38e-aea7-4294-b833-05dcff3e0536" | |
} | |
], | |
"sid": "FF850b19fc7238315001ddee9da3fed292" | |
}, | |
{ | |
"name": "amountSelection", | |
"type": "Gather", | |
"properties": { | |
"offset": { | |
"x": 500, | |
"y": 250 | |
}, | |
"timeout": 5, | |
"finish_on_key": "#", | |
"stop_gather": true, | |
"number_of_digits": 1, | |
"save_response_as": null, | |
"say": "To donate 5 dollars, press 1.\nTo donate 10 dollars, press 2.\nTo donate 20 dollars, press 3.", | |
"play": null, | |
"voice": "alice", | |
"language": "en-US", | |
"loop": 1, | |
"hints": null, | |
"gather_language": "en", | |
"speech_timeout": null, | |
"speech_model": null, | |
"profanity_filter": null | |
}, | |
"transitions": [ | |
{ | |
"event": "keypress", | |
"conditions": [], | |
"next": "FF958328fe9eb03a646bad0945c6999b55", | |
"uuid": "d3297b1f-92d3-4396-a91c-55e6ccf19dd6" | |
}, | |
{ | |
"event": "speech", | |
"conditions": [], | |
"next": null, | |
"uuid": "6cdcb081-f885-45d9-aced-f7704ed29abf" | |
}, | |
{ | |
"event": "timeout", | |
"conditions": [], | |
"next": null, | |
"uuid": "1305712c-befe-42c8-ba54-7e4a8a29319b" | |
} | |
], | |
"sid": "FF929ed07da7d5321cc764b5aff30228ea" | |
}, | |
{ | |
"name": "amountSet", | |
"type": "SetVariables", | |
"properties": { | |
"offset": { | |
"x": -44, | |
"y": 468 | |
}, | |
"variables": [ | |
{ | |
"key": "amount", | |
"value": "{% assign input = widgets.amountSelection.Digits %}{% if input == '1' %}{% assign res = '5.00' %}{% elsif input == '2' %}{% assign res = '10.00' %}{% elsif input == '3' %}{% assign res = '20.00' %}{% else %}{% assign res = '9.99' %}{% endif %}{{res | strip_newlines}}", | |
"index": "0" | |
} | |
] | |
}, | |
"transitions": [ | |
{ | |
"event": "next", | |
"conditions": [], | |
"next": "FF521b039652f148adfe354169826b9628", | |
"uuid": "707fb537-5793-471b-8067-89ad7562496e" | |
} | |
], | |
"sid": "FF958328fe9eb03a646bad0945c6999b55" | |
}, | |
{ | |
"name": "successMessage", | |
"type": "SayPlay", | |
"properties": { | |
"offset": { | |
"x": -443, | |
"y": 973 | |
}, | |
"say": "Thank you for your donation.", | |
"play": null, | |
"voice": "alice", | |
"language": "en-US", | |
"loop": 1, | |
"digits": null | |
}, | |
"transitions": [ | |
{ | |
"event": "audioComplete", | |
"conditions": [], | |
"next": null, | |
"uuid": "b77f5cf8-46c9-4b67-a289-1da93a2f3d47" | |
} | |
], | |
"sid": "FF64b837e6fd18a621439846372f4e83f0" | |
}, | |
{ | |
"name": "errorProvider", | |
"type": "SayPlay", | |
"properties": { | |
"offset": { | |
"x": 0, | |
"y": 970 | |
}, | |
"say": "Error with provider", | |
"play": null, | |
"voice": "alice", | |
"language": "en-US", | |
"loop": 1, | |
"digits": null | |
}, | |
"transitions": [ | |
{ | |
"event": "audioComplete", | |
"conditions": [], | |
"next": null, | |
"uuid": "9e1ae422-2e38-4336-a3b6-7b04333eeb51" | |
} | |
], | |
"sid": "FF7115346f1f14b95f7586a2bc219d51c8" | |
}, | |
{ | |
"name": "errorGeneral", | |
"type": "SayPlay", | |
"properties": { | |
"offset": { | |
"x": 375, | |
"y": 975 | |
}, | |
"say": "Error", | |
"play": null, | |
"voice": null, | |
"language": "en-US", | |
"loop": 1, | |
"digits": null | |
}, | |
"transitions": [ | |
{ | |
"event": "audioComplete", | |
"conditions": [], | |
"next": null, | |
"uuid": "e5e5465d-1aea-4dd5-b6fe-044dbc27f3f8" | |
} | |
], | |
"sid": "FF382b6a08549a6faa66e8ac6dac7ae89b" | |
} | |
] | |
} |
Hey @sbleitner,
Thank you! Sadly, no, I don't have code for a custom amount. I don't work at Twilio anymore, so haven't played around with Studio in a while. However, I believe that if you add another "Gather input" widget after the one that code has with the defined amounts, you should be able to capture a custom input from users.
Best!
Thanks! I will give it a shot but I'm no programmer, hope it's simple
enough...
…On Mon, 3 Aug 2020, 2:31 am Fernando Larrañaga, ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Hey @sbleitner <https://github.com/sbleitner>,
Thank you! Sadly, no, I don't have code for a custom amount. I don't work
at Twilio anymore, so haven't played around with Studio in a while.
However, I believe that if you add another "Gather input" widget after the
one that code has with the defined amounts, you should be able to capture a
custom input from users.
Best!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://gist.github.com/7127ef1318885401f892049dd54ee275#gistcomment-3401485>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOUXNZHYQYIUIKOPCFGNNDR6YHOLANCNFSM4PBWP7BA>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fernando, Thanks for this Twilio donation flow!
Do you by any chance have code that let's the caller enter a custom amount that they wish to donate? Many thanks,