DESCUBRE lo que puedes crear con Twilio

Juega con una demostración del menú del teléfono y descubre cómo funciona.

DESCUBRE LO QUE PUEDES CREAR CON TWILIO

Llama al (323) 992-0315 e ingresa el código 6240

(No te preocupes, no almacenaremos tu número de teléfono ni lo usaremos después de esta demostración).

¡Ahoy!

Llámanos al (323) 992-0315 e ingresa “6240”. Esto vinculará tu llamada con este editor de texto. A continuación, personalizaremos el mensaje que escuchas cuando llamas al sistema IVR.

Siguiente: personaliza el menú del teléfono


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>

¿En la línea? Genial, deberías escuchar el mensaje de bienvenida allí. Puedes realizar cambios en este mensaje de bienvenida y volver a llamar o presiona * para escuchar tus ediciones.

Excelente. A continuación, profundizaremos en las instrucciones que puedes utilizar para decirle a Twilio cómo deseas que maneje llamadas.

Siguiente:  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>

La forma en que controlas las llamadas en Twilio es con TwiML, Twilio Markup Language. Tu código TwiML le indica a Twilio qué hacer cuando tu aplicación recibe una nueva llamada telefónica. Puedes escribir TwiML con XML sin procesar o utilizar tu lenguaje de servidor preferido (y nuestras bibliotecas de ayuda), como las que tenemos a la derecha.

El verbo <Say> (decir) de TwiML indica a Twilio que lea este texto dinámico al agente de llamada, y ofrece más de 50 voces en 25 idiomas. Para reproducir cualquier tipo de archivo de audio, como mensajes pregrabados o música, a tus agentes de llamada, utiliza <Play> (reproducir).

El verbo <Gather> (reunir) de TwiML recopilará los dígitos o transcribirá el discurso del agente de llamada. Cuando el agente de llamada termina, Twilio envía los datos a la URL de “acción” proporcionada.

Siguiente: Elige el comando sobre el que deseas obtener más información: <Dial> (marcar), <Record> (grabar) o SMS (enviar 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>

El verbo <Dial> (marcar) dirigirá al agente de llamada al lugar correcto, ya sea a otro número, una llamada de conferencia, un agente o incluso una SIM de red inalámbrica programable.

En este ejemplo, utilizamos <Dial> (marcar) para dirigirte al sistema IVR de soporte de Twilio que nuestros clientes utilizan para conectarse con nuestros equipos de ventas, soporte y atención.

¡Gracias por probar esto!

Regístrate gratis en tu cuenta de Twilio para obtener tu propio número de Twilio y crear tu primer menú del teléfono programable.


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

Sumérgete en un tutorial del menú del teléfono con una aplicación de muestra completa en funcionamiento

Consulta el resto del código necesario para llevar tu IVR de Twilio a producción.

Flowchart

Explora qué más puedes crear con Twilio

Revisa estos proyectos de muestra listos para la producción a fin de realizar verificaciones telefónicas, recordatorios de citas, chat web y mucho más.

Flowchart

Diseña un menú del teléfono arrastrando y soltando elementos

Ahorra tiempo y sprints con Twilio&nbsp;Studio. Cualquier persona de tu equipo puede crear o modificar flujos de voz mediante tu código o el código de Twilio, todo dentro de una estructura común.