This is a Node.js console application, which is intended to illustrate how a user can interact with the Payment Resource in order to facilitate agent-assisted payments over the phone.
You must have installed the following tools:
- Ngrok
You must have an installed Pay Connector and a staging or mock payment processor. You can work through this Generic Pay Connector Tutorial to set up both of these things.
Part of understanding how a payment session works is hearing the audio for both parties in a call. Since most of us have one cell phone, we can use the Twilio Dev-Phone as a browser-based phone who will be our "agent". (Make sure you buy a new phone number and call it "Dev Phone" that you can always use with the Dev Phone).
Open up a terminal and start your ngrok tunnel for port 3000. If you have a custom domain, the command will be: ngrok http --region=us --hostname=mydemotunnel.ngrok.io 3000
otherwise, the command will be ngrok http --region=us 3000
. Leave this terminal open and running!
- Buy a Twilio Phone Number and give it a friendly name like
My Agent Assist Demo Number
. This is the phone number your "customer" will call. - On the Phone Number's configuration page, for "When a call comes in" select "Webhook" and
https://
+ your ngrok tunnel domain +/twiml
(ex:https://briannastunnel.ngrok.io/twiml
).
This demo application has a /twiml
endpoint that will return TwiML to Twilio. It tells Twilio to <Dial>
the phone number of your "agent". In this case, that can be your Twilio Dev Phone's phone number, or it could also just be a coworker's cell phone, your home's landline phone number, another cell phone you have, etc.
If you're using the Twilio Dev Phone, open a NEW terminal window and start the dev phone: twilio dev-phone
. Leave this terminal open and running!
- Open yet another terminal window and navigate to where you want to install the repository.
- Clone this repo:
git clone https://github.com/TwilioDevEd/agent-assist-demo-console-app.git
- Change directories into the root of the project:
cd agent-assist-demo-console-app
- Install the dependencies:
npm install
- Copy the
.env.example
file to make a.env
file:cp .env.example .env
. - Open the
.env
file in your text/code editor. (You may be able to use the commandopen .env
. If you have VS Code and thecode
command configured, you could also use the commandcode .env
) - Fill in the information in the
.env
file and SAVE your changes.
ACCOUNT_SID
: This is found on the dashboard of your Twilio ConsoleAUTH_TOKEN
: This is also found on the dashboard of your Twilio ConsoleAGENT_PHONE_NUMBER
: This is the number for the cell phone/landline/Twilio Dev Phone that will serve as your "agent". This isn't the number your customer will dial, but rather is the number that Twilio will<Dial>
when yourMy Agent Assist Demo Number
Twilio Phone Number recieves a call.YOUR_NGROK_DOMAIN
: The domain of your ngrok tunnel. Something likemytunnel.ngrok.io
or123124aaaaaf.ngrok.io
. (Don't addhttps:
or any slashes.)YOUR_PAYMENT_CONNECTOR_NAME
: This is the Friendly Name of the Pay Connector you will use for this demo.YOUR_TWILIO_NUMBER
: This is the phone number your "customer" will call. This is the phone number you bought earlier and namedMy Agent Assist Demo Number
.
Make sure you have:
- Your ngrok tunnel running on port 3000
- Your
My Agent Assist Demo Number
phone number is configured to use the ngrok domain from step 1 (with/twiml
appended on the end) when a call comes in. - Have your Twilio Dev Phone running (if applicable).
- Open a new terminal window, navigate to the root of the project (in the same directory as the
package.json
file), and run the following command:npm run start
.
You can enter ctrl + c
to stop the application.