This project uses Laravel Sail, (if running over Windows, Laravel Sail requires WSL2, and won't run in HyperV).
NOTE:
By default, Sail commands are invoked using the vendor/bin/sail
script that is included with all new
Laravel applications.
However, instead of repeatedly typing vendor/bin/sail
to execute Sail commands, you may wish
to configure a shell alias that allows you to execute Sail's commands more easily:
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
- Clone the project
[email protected]:rogerio-pereira/Laravel-OTP-email_sms_voice.git ./LaravelOTP
- Access project folder
cd LaravelOTP
- Copy .env file
cp .env.example .env
- Update
.env
fileAPP_NAME= DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE= DB_USERNAME= DB_PASSWORD= #FORWARD_DB_PORT= #Use if port 3306 is already assigned REDIS_HOST=127.0.0.1 REDIS_PASSWORD=null REDIS_PORT=6379 #FORWARD_REDIS_PORT= #Use if port 6379 is already assigned MAIL_MAILER=ses MAIL_FROM_ADDRESS="[email protected]" #Use an email validated in SES MAIL_FROM_NAME="${APP_NAME}" AWS_ACCESS_KEY_ID=<AWS Access Key, step 18> AWS_SECRET_ACCESS_KEY=<AWS Access Key, step 19> AWS_CONNECT_INSTANCE_ID=<AWS CONNECT, step 19> AWS_CONNECT_QUEUE_ID=<AWS CONNECT, step 19> AWS_CONNECT_CONTACT_FLOW_ID=<AWS CONNECT, step 52>
- Install composer dependencies
docker run --rm \ -u "$(id -u):$(id -g)" \ -v "$(pwd):/var/www/html" \ -w /var/www/html \ laravelsail/php83-composer:latest \ composer install --ignore-platform-reqs
- Generate app key
sail artisan key:generate
- Start the containers
sail up -d
- Run migrations
sail artisan migrate
- Compile js
sail npm run build
- Run tests
sail test --parallel
- Clear cache
sail artisan optimize:clear
- Go to IAM Page
- On Left Menu > Access management >
Users
- Click
Create User
- Add a
Username
- Click Next
- Select
Attach policies directly
- Add following permissions
- AmazonSESFullAccess
- AmazonSNSFullAccess
- AmazonConnect_FullAccess
- AmazonSQSFullAccess
- AmazonS3FullAccess
- Click Next
- Click Create users
- In the table click the user
- Click
Security Credentials
- Scroll down to Access Keys
- Click
Create Access Key
- Select the use case
NOTE: Select
Local code
orApplication running on an AWS compute service
depending on your use case - Check option
I understand the above..
- Click Next
- Click Create Access Key
- Copy
Access Key
- Copy
Secret access key
- Click
Done
- Go to AWS SES Page
- On Left Menu > Configuration >
Verified identities
- Click
Create Identity
- Select
Email Address
- Type Email address
- Click Create Identity
- Access your email
- Check for AWS email
Amazon Web Services – Email Address Verification Request in region <region name>
NOTE: Might be on span folder - Click the link to verify the indentity
- Go to AWS SES Page again
- On Left Menu > Configuration >
Verified identities
- Select email
- Click
Send test email
- Select
Custom
in Scenarion - Type the same verified email (step 5) in
Custom recipient
field - Type a message
- Click Send Test Email
- Go to AWS SES Page again
- On Left Menu >
Get set up
- Scroll down to
Get production access and start sending emails
section - Click
Create Identity
- Select Domain
- Type the domain
- Click
Create Identity
- Scroll down to
DomainKeys Identified Mail (DKIM)
section - Add all records to your domain DNS
- Wait until the DNS records are verified NOTE: It might take up to 24 hours for the DNS records to be verified
After everything is tested you need to request Production access (leave sandbox)
- Go to AWS SES Page again
- On Left Menu >
Get set up
- Click
Request production access
- Select
Transactional
on Mail Type - Type your website in
Website URL
- In
Use case description
be very specific on:- How do you plan to build or acquire your mailing list?
- How do you plan to handle bounces and complaints?
- How can recipients opt out of receiving email from you?
NOTE: Add as much detail as possible (this field is crucial on AWS Team allowing your account to leave sandbox)
- Select your
Prefered contact language
- Select
I agree to ...
- Click
Submit Request
- Wait for a response
- Go to AWS SNS Page
- On Left Menu > Mobile >
Origination Number
- Click
Provision numbers in Pinpoint
- Click
Request Phone Number
- Select the Country
- Select Tool-free
- Make sure voice and SMS are checked
- Select Default message type > Transactional
- Click Next
- Click Request
- Click the Phone number and you'll be redirected to AWS Pinpoint page
- Click on left Menu > Configurations > Registrations
- Click
Create Registration
- Add name on field
Registration friendly name
- Registration Type >
US tool-free number registration
- On
Available toll-free numbers
select the number - Click Create
- Fill the
Company info
form - Click Next
- Fill the
Contact info
form - Click Next
- Fill the
Message use case
form
NOTE: OnUse case details
andOpt-in workflow description
be as much specific as possible
NOTE2: You are required to send an otp-in workflow, use this image
- Click Next
- Sample message
Hello, new OTP (OneTimePassword) XXXXXX for application XYZ
- Click Next
- Click Submit Registration
- Wait until the the number is provisioned (can take up to 15 business days) (for me it took 14 business day, 21 day in total)
NOTE: Do this step only after the phone number requested in SNS (Origination Number) is active
- Go to AWS SNS Page
- On Left Menu > Mobile > Text Messaging (SMS)
- Scroll down to
Sandbox destination phone number
- Click
Add Phone number
- type your phone number
- Select a language
- Click
Add phone number
- Go to AWS SNS Page
- On Left Menu > Mobile > Text Messaging (SMS)
- Scroll down to
Sandbox destination phone number
- Select the phone number
- Click verify Phone Number
- Type the code sent to that number
- Go to AWS Connect Page
- Click Add Instance
Identity
Page- Select
Store users in Amazon Connect
- Type an URL
eg. connect - Click Next
Administrator
Page- Select Specify Administrator
- Fill fields:
a.First Name
b.Last Name
c.Username
d.Password
e.Password (verify)
f.Email
- Click Next
Telephony
Page- Uncheck
Allow incoming calls
- Click Next
Data Storage
Page- Copy
Connect Data
bucket - Copy
Flow Logs
cloudwatch - Click Next
- Review and Create Page
- Click Create Instance
- Wait until everything is created
- Click your access URL
- Fill username and password and click
Sign In
NOTE: Defined inAWS Connect Configuration
> Step 9.c and 9.d - In section
Explore you channels of communications
- Click Begin
- Select
Tool free
inType
field - Select Country
- The phone number will be selected automatically NOTE: This phone number isn't related to SNS (Origination Number)
- Click Next
- Click Continue
- On Connect Home, scroll down to
Create Queues
section - Click
View queues
- Click
BasicQueue
- Scroll down to
Outbound caller configuration
- Fill
Default Caller ID
- Select phone number in
Outbound caller ID number
- Click Save
- Click
BasicQueue
again - Click
Show additional queue information
- You’ll get an ARN in the form of
arn:aws:connect:<region>:<account-id>:instance/<instance-id>/queue/<queue-id>
- Copy
instance-id
andqueue-id
and update .env (see below) - On Connect Home, scroll down to
Create flows
section - Click
View flows
- On the arrow next to
Create Flow
- Click
Create flow
- Enter a flow name
- Search, drag and drop
Play prompt
- Click the three dots and
Edit Settings
- Select
Text to speech or chat text
- Select
Set Dynamically
- Select
User defined
in namespace - Type
message
inkey
- Select
SSML
in Interpret as - Click Save
- Connect Start with
Play prompt block
- Search, drag and drop
Get Customer input
- Click the three dots and
Edit Settings
- Select
Text to speech or chat text
- Select
Set Manually
- Enter text
<speak>Press 1 to repeat.</speak>
- Select
Text
in Interpret as - Click
DTMF
- Set timeout as
5
- Click
Add condition
- Type
1
- Type
Enter
- Click Save
- Search, drag and drop
End flow
- Connect blocks as follows
- Click Save
- Click Publish
- Click
Show additional flow information
- You’ll get an ARN in the form of
arn:aws:connect:<region>:<account-id>:instance/<instance-id>/contact-flow/<contact-flow-id>
- Copy
contact-flow-id
and update .env (see below)