Fazer uma ligação
Para iniciar a chamada após pressionar o START CALL botão preencher o corpo do startCall método interno Mainctivity classe:
@SuppressLint("MissingPermission")
fun startCall() {
client.serverCall(mapOf("to" to "PHONE_NUMBER")) {
err, outboundCall ->
when {
err != null -> {
connectionStatusTextView.text = err.localizedMessage
}
else -> {
startCallButton.visibility = View.INVISIBLE
endCallButton.visibility = View.VISIBLE
}
}
}
}
Certifique-se de substituir PHONE_NUMBER abaixo, com o número de telefone que você deseja ligar, no E.164 formato (por exemplo, 447700900000).
NOTA: Certifique-se de que o servidor de webhook que você configurou nas etapas anteriores ainda esteja em funcionamento.
Webhooks
À medida que você for realizando a ligação, por favor, mude para o terminal e observe o /voice/answer endpoint chamado para recuperar o NCCO:
Além disso, à medida que a chamada passa por várias etapas, /voice/event está recebendo eventos:
...
---
VOICE EVENT:
{
from: null,
to: 'Alice',
uuid: '2da93da3-bcac-47ee-b48e-4a18fae7db08',
conversation_uuid: 'CON-1a28b1f8-0831-44e6-8d58-42739e7d4c77',
status: 'started',
direction: 'inbound',
timestamp: '2021-03-10T10:36:21.285Z'
}
---
VOICE EVENT:
{
headers: {},
from: 'Alice',
to: '447700900000',
uuid: '8aa86e22-8d45-4201-b8d8-3dcd76e76429',
conversation_uuid: 'CON-1a28b1f8-0831-44e6-8d58-42739e7d4c77',
status: 'started',
direction: 'outbound',
timestamp: '2021-03-10T10:36:27.080Z'
}
---
...
---
VOICE EVENT:
{
start_time: null,
headers: {},
rate: null,
from: 'Alice',
to: '447700900000',
uuid: '8aa86e22-8d45-4201-b8d8-3dcd76e76429',
conversation_uuid: 'CON-1a28b1f8-0831-44e6-8d58-42739e7d4c77',
status: 'answered',
direction: 'outbound',
network: null,
timestamp: '2021-03-10T10:36:31.604Z'
}
---
VOICE EVENT:
{
headers: {},
end_time: '2021-03-10T10:36:36.000Z',
uuid: '8aa86e22-8d45-4201-b8d8-3dcd76e76429',
network: '23433',
duration: '5',
start_time: '2021-03-10T10:36:31.000Z',
rate: '0.10000000',
price: '0.00833333',
from: 'Unknown',
to: '447700900000',
conversation_uuid: 'CON-1a28b1f8-0831-44e6-8d58-42739e7d4c77',
status: 'completed',
direction: 'outbound',
timestamp: '2021-03-10T10:36:35.585Z'
}
---
VOICE EVENT:
{
headers: {},
end_time: '2021-03-10T10:36:35.000Z',
uuid: '2da93da3-bcac-47ee-b48e-4a18fae7db08',
network: null,
duration: '15',
start_time: '2021-03-10T10:36:20.000Z',
rate: '0.00',
price: '0',
from: null,
to: 'Alice',
conversation_uuid: 'CON-1a28b1f8-0831-44e6-8d58-42739e7d4c77',
status: 'completed',
direction: 'inbound',
timestamp: '2021-03-10T10:36:36.187Z'
}
NOTA: Assim que a chamada for concluída, os eventos também conterão informações sobre a duração e o preço.
O END CALL O botão foi exibido para refletir o estado atual da chamada:

Fazendo uma chamada de voz no aplicativo
Faça uma chamada de voz a partir de um aplicativo Android para um telefone usando o Client SDK do Android.