Skip to content

Commit f51e837

Browse files
authored
adding transfer call with inline ncco.
1 parent dee9ef3 commit f51e837

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

voice/transfer-call-inline-ncco.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Import dependencies
2+
import nexmo
3+
import os
4+
from os.path import join, dirname
5+
from dotenv import load_dotenv
6+
7+
# Load the environment
8+
envpath = join(dirname(__file__), './.env')
9+
load_dotenv(envpath)
10+
11+
# Init the client
12+
print(os.getenv("NEXMO_PRIVATE_KEY"))
13+
client = nexmo.Client(
14+
application_id=os.getenv('NEXMO_APPLICATION_ID'),
15+
private_key=os.getenv("NEXMO_PRIVATE_KEY")
16+
)
17+
18+
response = client.create_call({
19+
"to": [{"type": "phone", "number": os.getenv('TO_NUMBER')}],
20+
"from": {"type": "phone", "number": os.getenv('FROM_NUMBER')},
21+
"ncco": [
22+
{
23+
"action": "talk",
24+
"text": "This is just a text whilst you tranfer to another NCCO"
25+
}
26+
]
27+
})
28+
29+
response = client.update_call(
30+
response["uuid"], {
31+
"action": "transfer",
32+
"destination": {
33+
"type": "ncco",
34+
"ncco": [{"action": "talk", "text": "hello world"}]
35+
}
36+
}
37+
)
38+
39+
40+
print(response)

0 commit comments

Comments
 (0)