michaelrkn / vpb-preview-dialer

0 stars 0 forks source link

#7 automate deployment, #2 logrocket #9

Closed djake closed 4 years ago

djake commented 4 years ago

See the read me for updates on deployment.

Generally, this adds the functions to version control, adds npm run deploy (and npm run start but that isn't yet very useful), moves the extension source to /extensions, provides an upgrade path to the new deployments, does not set a 400 when already verified.

I have deployed this to the development account and have redirected the voice app to the new functions. To revert the changes and run through the whole process yourself, you could reset the callback to https://cardinal-moose-3646.twil.io/client-voice, copy the contents of twilio-config/.test-twilio-functions into .twilio-functions and configure .env for the test account, then delete the service from the cli (I haven't done it but it would be something like twilio api:serverless:v1:services:remove --sid <serviceSid from .twilio-functions>

To onboard a new client you'd have to create a legacy-update function/campaign code. We can change that going forward, I'm assuming that's not an active problem.

Twilio has a concept of a "production" environment. As far as I've seen the only difference is there is no suffix at the end of the subdomain (I am using "public" in this PR), so, didn't seem like it was worth the extra steps * existing accounts.

I think this works on my machine. Chrome extensions, the details of the van ui, twilio, and the behavior of this extension are all relatively new to me. (In particular, I don't know how to simulate the update hook.) Me calling my own phone goes to voicemail, calling your phone google seems to screen immediately. So, please do whatever Q/A is necessary for you to feel comfortable with this.

michaelrkn commented 4 years ago

I think consolidating makes sense so that we don't have to maintain two codebases for dev and prod. Prod actually is a little problematic right now though: I manually create a new Twilio account for each customer, and then re-deploy the functions on that account. It would be much better to have subaccounts so that we can use the same functions for each one, and then just use env vars (or better yet, eventually have a database of some sort) for their credentials.

djake commented 4 years ago

The follow on to my question about the separate accounts was going to be that it might be simpler technically to have one account since the old urls will not be valid (once we update something), and we don't want to distribute new codes right now. I am pretty sure I can insert the campaign code into the url if that is desirable, but it appears the new urls have random bits (3049, below). Maybe we can add a twilioDomain prop to localStorage, and if it is empty, hit a /getDomain function that we (you) will add manually to the existing deployments which just returns a NEW_DOMAIN env var for that user account which we can set in the extension?

djakelambert@dj:vpb-preview-dialer (7-automate-deployment<>)$ npm run deploy

> vpb-preview-dialer@1.0.0 deploy /Users/djakelambert/Documents/Development/vpb-preview-dialer
> twilio-run deploy --environment=public --no-assets

Deploying functions & assets to the Twilio Runtime

Account         <REDACTED>
Token           <REDACTED>
Service Name    vpb-preview-dialer
Environment     public
Root Directory  /Users/djakelambert/Documents/Development/vpb-preview-dialer
Dependencies
Env Variables   ACCESS_CODE, CAMPAIGN_CODE

✔ Serverless project successfully deployed

Deployment Details
Domain: vpb-preview-dialer-3049-public.twil.io
Service:
   vpb-preview-dialer (ZSf60467999d3273715251a0f22fcd4c1e)
Environment:
   public (ZE35b1ef7ee8e04a6c32c03fdbf3a86cc5) 
Build SID:
   ZBa37b4ce20513eed274c00b79f09a95d4
View Live Logs:
   https://www.twilio.com/console/assets/api/ZSf60467999d3273715251a0f22fcd4c1e/environment/ZE35b1ef7ee8e04a6c32c03fdbf3a86cc5
Functions:
   https://vpb-preview-dialer-3049-public.twil.io/capability-token
   https://vpb-preview-dialer-3049-public.twil.io/check-caller-id
   https://vpb-preview-dialer-3049-public.twil.io/client-voice
   https://vpb-preview-dialer-3049-public.twil.io/verify-caller-id
Assets:
michaelrkn commented 4 years ago

That all sounds good to me!