Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

[wip] Update to use Twilio voice sdk 2.0#12

Draft
sarahcstringer wants to merge 30 commits into
nextfrom
update-voice-sdk-2.0
Draft

[wip] Update to use Twilio voice sdk 2.0#12
sarahcstringer wants to merge 30 commits into
nextfrom
update-voice-sdk-2.0

Conversation

@sarahcstringer

Copy link
Copy Markdown

No description provided.

Sarah Stringer added 18 commits June 2, 2021 15:57
enableRingingState and fakeLocalDtmf default to True in
the 2.x versions of Twilio Voice SDK.
The Device object is now lazy about opening the signaling connection.
`new Device(...)` is synchronous and will not cause a signaling channel
to be opened, and the "ready" event won't be fired.
…bject.

These events are now fired for Call objects instead of Device objects.
No functional change -- in the Twilio voice sdk 2.0, internal
Connection objects were renamed to Call objects, so this is a
semantic change to be in line with the internals.
These functions were previously not working because they did not have
access to the device.
This is to disambiguate the payload that Twilio sends for inbound
calls. The payload typically includes a "To" field already.

@onlywade onlywade left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work! Aside from the SDK upgrade, I dig the small improvements around comments, naming, and overall organization.

While I don't have much insight into the SDK, or Javascript best practices or style guidelines, etc, I can at least say that everything passes the sniff test as far as I'm concerned. Also, fwiw, the demo runs great using this branch and following the readme. 👍

Comment thread app.py Outdated
resp = VoiceResponse()
if "To" in request.form and request.form["To"] != '':
dial = Dial(caller_id=os.environ['TWILIO_CALLER_ID'])
if request.form.get("To") and request.form["To"] == twilio_number:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume that having two distinct conditional checks here may be intentional, for purposes of clarity. Personally, though, I would consider consolidating them into a single conditional, to be more concise:

if request.form.get("To") == twilio_number:

Just a minor preference - either way reads okay.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, the two checks were redundant 👍 I'll update.

@stern-shawn stern-shawn left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this and the detailed readme changes!

I can't speak to the usage of the Twilio client itself, but I have some small JS-specific nits to toss into the ring 😆

Comment thread static/quickstart.js Outdated
Comment thread static/quickstart.js Outdated
Comment thread static/quickstart.js Outdated
Comment thread static/quickstart.js Outdated

speakerDevices.addEventListener("change", function () {
var selectedDevices = [].slice
const selectedDevices = [].slice

@stern-shawn stern-shawn Jun 7, 2021

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this got dredged up by the var -> const change, haha.

[].slice.call is a pretty esoteric way to convert a NodeList into an Array. Would recommend using the more readable/beginner-friendly Array.from method. MDN link

Suggested change
const selectedDevices = [].slice
const selectedDevices = Array.from(speakerDevices.children)
.filter((node) => node.selected); // the filter function can also be shortened :)

Comment thread static/quickstart.js Outdated

ringtoneDevices.addEventListener("change", function () {
var selectedDevices = [].slice
const selectedDevices = [].slice

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the other comment on [].slice.call

Sarah Stringer added 3 commits June 8, 2021 16:49
Remove example of creating a new API key via the twilio cli,
because doing so requires retrieving the account's auth token.

Also, make a note that the API_KEY is the key's SID.
Sarah Stringer added 4 commits June 10, 2021 10:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants