-
Notifications
You must be signed in to change notification settings - Fork 57
Add new building blocks. #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
eb0b464
Added connect an inbound call building block.
e0ccc53
Added from number and removed blank line. Tested.
7a57c7f
Use RECIPIENT_NUMBER rather than TO_NUMBER.
4fbaa42
Ignore Mac system file. Added building block. Fixed port on building …
d5c0adf
Another building block plus fixes.
18e57e9
New building block, plus fixed view response code (was missing).
0013292
Formatting fix
cf815b8
Fixed block to comply with spec (no welcome message). Plus two new bl…
48a8309
Ignore all private keys. Improved building block to comply more with …
aae93d4
Pedantic change to make sure time interval exactly 24 hours.
e18ed58
File is appears to be example.env. Plus a few minor typos fixed.
e8a335b
Add new building block.
c9dcd14
New building block.
fd7ad0e
Add a new building block.
67e6334
New building block.
154b9bc
Building block for join-outbound-calls
aa029b9
Updated based on Mark's feedback.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
from flask import Flask, request, jsonify | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "connect", | ||
"from": "NEXMO_NUMBER", | ||
"endpoint": [{ | ||
"type": 'phone', | ||
"number": "RECIPIENT_NUMBER" | ||
}] | ||
} | ||
] | ||
return jsonify(ncco) | ||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python3 | ||
from flask import Flask, request, jsonify | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "talk", | ||
"text": "Please wait while we connect you to the conference" | ||
}, | ||
{ | ||
"action": "conversation", | ||
"name": CONF_NAME | ||
}] | ||
return jsonify(ncco) | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
import nexmo | ||
import time | ||
from pprint import pprint | ||
|
||
client = nexmo.Client( | ||
application_id=APPLICATION_ID, | ||
private_key=APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
|
||
response = client.update_call(UUID, action="earmuff") | ||
pprint(response) | ||
time.sleep(5) | ||
response = client.update_call(UUID, action="unearmuff") | ||
pprint(response) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
from flask import Flask, request, jsonify | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "connect", | ||
"from": "NEXMO_NUMBER", | ||
"endpoint": [{ | ||
"type": 'phone', | ||
"number": "RECIPIENT_NUMBER_1" | ||
}] | ||
}, | ||
{ | ||
"action": "connect", | ||
"from": "NEXMO_NUMBER", | ||
"endpoint": [{ | ||
"type": 'phone', | ||
"number": "RECIPIENT_NUMBER_2" | ||
}] | ||
} | ||
] | ||
return jsonify(ncco) | ||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python3 | ||
import nexmo | ||
import time | ||
from pprint import pprint | ||
|
||
client = nexmo.Client( | ||
application_id=APPLICATION_ID, | ||
private_key=APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
|
||
response = client.update_call(UUID, action="mute") | ||
pprint(response) | ||
time.sleep(5) | ||
response = client.update_call(UUID, action="unmute") | ||
pprint(response) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env python3 | ||
from flask import Flask, request, jsonify | ||
from pprint import pprint | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "talk", | ||
"text": "Hi, we will shortly forward your call. This call is recorded for quality assurance purposes." | ||
}, | ||
{ | ||
"action": "record", | ||
"split" : "conversation", | ||
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"] | ||
}, | ||
{ | ||
"action": "connect", | ||
"eventUrl": ["https://demo.ngrok.io/webhooks/event"], | ||
"from": "NEXMO_NUMBER", | ||
"endpoint": [ | ||
{ | ||
"type": "phone", | ||
"number": "RECIPIENT_NUMBER" | ||
} | ||
] | ||
} | ||
] | ||
return jsonify(ncco) | ||
|
||
@app.route("/webhooks/recordings", methods=['POST']) | ||
def recordings(): | ||
data = request.get_json() | ||
pprint(data) | ||
return "Webhook received" | ||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
from flask import Flask, request, jsonify | ||
from pprint import pprint | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "talk", | ||
"text": "Hi, we will shortly forward your call. This call is recorded for quality assurance purposes." | ||
}, | ||
{ | ||
"action": "record", | ||
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"] | ||
}, | ||
{ | ||
"action": "connect", | ||
"eventUrl": ["https://demo.ngrok.io/webhooks/event"], | ||
"from": "NEXMO_NUMBER", | ||
"endpoint": [ | ||
{ | ||
"type": "phone", | ||
"number": "RECIPIENT_NUMBER" | ||
} | ||
] | ||
} | ||
] | ||
return jsonify(ncco) | ||
|
||
@app.route("/webhooks/recordings", methods=['POST']) | ||
def recordings(): | ||
data = request.get_json() | ||
pprint(data) | ||
return "webhook received" | ||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env python3 | ||
# `eventMethod` is a required workaround currently, otherwise `/webhooks/recordings` is never called. | ||
from flask import Flask, request, jsonify | ||
from pprint import pprint | ||
|
||
app = Flask(__name__) | ||
|
||
@app.route("/webhooks/answer") | ||
def answer_call(): | ||
ncco = [ | ||
{ | ||
"action": "conversation", | ||
"name": "CONF_NAME", | ||
"record": "true", | ||
"eventMethod": "POST", | ||
"eventUrl": ["https://demo.ngrok.io/webhooks/recordings"] | ||
} | ||
] | ||
return jsonify(ncco) | ||
|
||
@app.route("/webhooks/recordings", methods=['POST']) | ||
def recordings(): | ||
data = request.get_json() | ||
pprint(data) | ||
return "Webhook received" | ||
|
||
if __name__ == '__main__': | ||
app.run(port=3000) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
import nexmo | ||
from pprint import pprint | ||
|
||
client = nexmo.Client( | ||
application_id=APPLICATION_ID, | ||
private_key=APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
|
||
# Note call can be made to current call or a completed call | ||
response = client.get_call("NEXMO_CALL_UUID") | ||
pprint(response) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python3 | ||
import nexmo | ||
from pprint import pprint | ||
from datetime import datetime, timedelta | ||
|
||
client = nexmo.Client( | ||
application_id=APPLICATION_ID, | ||
private_key=APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
|
||
NOW = datetime.utcnow() | ||
DATE_END = NOW.replace(microsecond=0).isoformat()+"Z" | ||
DATE_START = (NOW - timedelta(hours=24, minutes=00)).replace(microsecond=0).isoformat()+"Z" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
response = client.get_calls(date_start=DATE_START, date_end=DATE_END) | ||
calls = response['_embedded']['calls'] | ||
for call in calls: | ||
pprint(call) |
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env python3 | ||
import nexmo | ||
from pprint import pprint | ||
|
||
client = nexmo.Client( | ||
application_id=APPLICATION_ID, | ||
private_key=APPLICATION_PRIVATE_KEY_PATH, | ||
) | ||
|
||
dest = {"type": "ncco", "url": ["https://developer.nexmo.com/ncco/tts.json"]} | ||
response = client.update_call(UUID, action="transfer", destination=dest) | ||
pprint(response) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of pprint!