Veja o que você pode criar com a Twilio

Experimente uma demonstração do menu do telefone e veja como funciona.

VEJA O QUE VOCÊ PODE CRIAR COM A TWILIO

Ligue para (323) 992-0315 e digite o código 6240

(Não se preocupe, não armazenaremos seu número de telefone nem o usaremos após esta demonstração.)

Ahoy!

Ligue para (323) 992-0315 e digite "6240". Isso emparelhará sua chamada com este editor de texto. Em seguida, personalizaremos a mensagem que você ouve ao ligar para a URA.

Próximo: Personalize o menu do telefone

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "dtmf", numDigits: 1);
gather.Say("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you've made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.");

response.Append(gather);

Console.WriteLine(response.ToString());

var gather = new Gather(input: "dtmf", numDigits: 4);
gather.Say("Please enter the 4 digit code on your screen to get started");

response.Append(gather);

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Please enter the 4 digit code on your screen to get started.")
	.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF))
	.numDigits(4)
	.say(say)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
	input: 'dtmf',
	numDigits: '4',
});

gather.say('Please enter the 4 digit code on your screen to get started');

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'dtmf', 'numDigits' => '4']);
$gather->say('Please enter the 4 digit code on your screen to get started.');

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='dtmf', num_digits=4)
gather.say('Please enter the 4 digit code on your screen to get started.')

response.append(gather)

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.gather(numDigits: 4, input: 'dtmf') do |g|
    g.say(message: 'Please enter the 4 digit code on your screen to get started.')
  end
end

puts response

<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Please enter the 4 digit code on your screen to get started.</Say>
	</Gather>
</Response>
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you&rsquo;ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.")
&#x9;.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF))
	.numDigits(1)
	.say(say)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
  input: 'dtmf',
  numDigits: '1',
});

gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

console.log(response.toString());
<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'dtmf', 'numDigits' => '1']);
$gather->say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

echo $response;
from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='dtmf', num_digits=1)
gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')

response.append(gather)

print(response)
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
	r.gather(numDigits: 1, input: 'dtmf') do |g|
		g.say(message: 'Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')
	end
end

puts response
<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR. </Say>
	</Gather>
</Response>

Na linha? Ótimo, você deve ouvir a mensagem de boas-vindas. Você pode fazer alterações nesta mensagem de boas-vindas e retornar a chamada ou pressionar asterisco para ouvir suas edições.

Incrível! Agora, vamos dar instruções para você dizer à Twilio como atender as chamadas conforme suas preferências.

Próximo:  TwiML

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "dtmf", numDigits: 1);
gather.Say("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you've made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.");

response.Append(gather);

Console.WriteLine(response.ToString());
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you&rsquo;ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.")
&#x9;.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF))
	.numDigits(1)
	.say(say)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
  input: 'dtmf',
  numDigits: '1',
});

gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

console.log(response.toString());
<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'dtmf', 'numDigits' => '1']);
$gather->say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

echo $response;
from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='dtmf', num_digits=1)
gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')

response.append(gather)

print(response)
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
	r.gather(numDigits: 1, input: 'dtmf') do |g|
		g.say(message: 'Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')
	end
end

puts response
<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR. </Say>
	</Gather>
</Response>

A forma como você controla chamadas na Twilio é com a TwiML, a Twilio Markup Language. O código da TwiML informa à Twilio o que fazer quando o app recebe uma nova chamada telefônica. Você pode programar a TwiML com XML bruto ou usar uma linguagem de preferência no lado do servidor (e nossas bibliotecas auxiliares) como temos à direita.

O verbo <Say> (Falar) da TwiML é usado para a Twilio ler o texto dinâmico ao autor da chamada. Mais de 50 vozes em 25 idiomas são disponibilizadas. Para reproduzir qualquer tipo de arquivo de áudio, como mensagens ou músicas pré-gravadas, use o <Play> (Reproduzir).

O verbo <Gather> (Obter) da TwiML registra os dígitos ou transcreve a fala do autor da chamada. Quando o autor da chamada termina, a Twilio envia os dados para o URL "action" fornecido.

Próximo: Escolha o comando que deseja aprender: <Dial> (Chamar), <Record> (Gravar) ou SMS

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "speech dtmf", numDigits: 1);
gather.Say("Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.");

var play = new Play(new Uri("http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3"));
gather.Append(play);

response.Append(gather);

Console.WriteLine(response.ToString());
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.")
	.build();

Play play = new Play.Builder("http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3")
	.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF, Gather.Input.SPEECH))
	.numDigits(1)
	.say(say)
	.play(play)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
	input: 'speech dtmf',
	numDigits: '1',
});

gather.say('Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.');

gather.play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3');

console.log(response.toString());
<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'speech dtmf', 'numDigits' => '1']);
$gather->say('Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.');
$gather->play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3');

echo $response;
from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='speech dtmf', num_digits=1)
gather.say('Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.')
gather.play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3')

response.append(gather)

print(response)
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.gather(numDigits: 1, input: 'dtmf') do |g|
    g.say(message: 'Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.')
    g.play(url: 'http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3')
  end
end

puts response
<Response>
	<Gather input="speech dtmf" numDigits="1">
	<Say>Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.</Say>
	<Play>http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3</Play>
	</Gather>
</Response>

O verbo <Dial> (Chamar) encaminha o autor da chamada para o lugar certo, seja para outro número, chamada de conferência, agente ou até mesmo um chip/SIM Programmable Wireless.

Neste exemplo, usamos o <Dial> (Chamar) para encaminhar você à URA de suporte da Twilio, que os nossos clientes utilizam para entrar em contato com nossas equipes de vendas, suporte e recepção.

Obrigado por experimentar!

Crie uma conta gratuita da Twilio para obter um número da Twilio e criar seu primeiro menu do telefone programável.

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

response.Say("During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.");
response.Dial("+18448144627");

Console.WriteLine(response.ToString());
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.")
	.build();

Dial dial = new Dial.Builder("+18448144627")
	.build();

VoiceResponse response = new VoiceResponse.Builder()
	.say(say)
	.dial(dial)
	.build();

System.out.println(response.toXml());
const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

response.say('During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.');

response.dial('+18448144627');

console.log(response.toString());
<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$response->say('During an active call, you can use the Dial verb to connect the current caller to another party. We\'re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.');
$response->dial('+18448144627');

echo $response;
from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

response.say('During an active call, you can use the Dial verb to connect the current caller to another party. We\'re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.')
response.dial('+18448144627')

print(response)
require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.say(message: 'During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.')
  r.dial(number: '+18448144627')
end

puts response
<Response>
	<Say>During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.</Say>
	<Dial>+18448144627</Dial>
</Response>
Flowchart

Participe de um tutorial de menu do telefone com um aplicativo de amostra de trabalho completo

Veja o restante do código necessário para colocar a URA da Twilio em funcionamento.

Flowchart

Explore o que mais você pode criar com a Twilio

Confira estes projetos de amostra prontos para produção para verificações de telefone, lembretes de agendamento, chat na Web e muito mais.

Flowchart

Crie um menu do telefone arrastando e soltando

Economize tempo e sprints com o Twilio Studio. Qualquer pessoa em sua equipe pode criar ou modificar fluxos de voz usando seu código ou o código da Twilio, tudo dentro de uma estrutura em comum.