Search in sources :

Example 1 with Dial

use of com.twilio.twiml.voice.Dial in project api-snippets by TwilioDevEd.

the class Example method service.

public void service(final HttpServletRequest request, final HttpServletResponse response) throws IOException {
    Dial dial = new Dial.Builder().queue(new Queue.Builder("Queue Demo").build()).build();
    VoiceResponse voiceResponse = new VoiceResponse.Builder().dial(dial).build();
    try {
        response.getWriter().print(voiceResponse.toXml());
    } catch (TwiMLException e) {
        e.printStackTrace();
    }
}
Also used : Dial(com.twilio.twiml.voice.Dial) VoiceResponse(com.twilio.twiml.VoiceResponse) Queue(com.twilio.twiml.voice.Queue) TwiMLException(com.twilio.twiml.TwiMLException)

Example 2 with Dial

use of com.twilio.twiml.voice.Dial in project twilio-java by twilio.

the class TwiMLResponseExample method main.

/**
 * TwiML example usage.
 *
 * @param args command line args
 * @throws TwiMLException if cannot generate TwiML
 */
public static void main(final String[] args) throws TwiMLException, URISyntaxException {
    // Say
    Say say = new Say.Builder("Hello World!").voice(Say.Voice.MAN).loop(5).build();
    VoiceResponse response = new VoiceResponse.Builder().say(say).build();
    System.out.println(response.toXml());
    // Gather, Redirect
    Gather gather = new Gather.Builder().numDigits(10).say(new Say.Builder("Press 1").build()).build();
    Redirect redirect = new Redirect.Builder(new URI("https://example.com")).build();
    response = new VoiceResponse.Builder().gather(gather).redirect(redirect).build();
    System.out.println(response.toXml());
    // Conference
    Conference conference = new Conference.Builder("my room").beep(Conference.Beep.TRUE).build();
    Dial dial = new Dial.Builder().callerId("+1 (555) 555-5555").action(new URI("https:///example.com")).hangupOnStar(true).conference(conference).build();
    response = new VoiceResponse.Builder().dial(dial).build();
    System.out.println(response.toXml());
}
Also used : VoiceResponse(com.twilio.twiml.VoiceResponse) Say(com.twilio.twiml.voice.Say) Redirect(com.twilio.twiml.voice.Redirect) URI(java.net.URI) Conference(com.twilio.twiml.voice.Conference) Gather(com.twilio.twiml.voice.Gather) Dial(com.twilio.twiml.voice.Dial)

Aggregations

VoiceResponse (com.twilio.twiml.VoiceResponse)2 Dial (com.twilio.twiml.voice.Dial)2 TwiMLException (com.twilio.twiml.TwiMLException)1 Conference (com.twilio.twiml.voice.Conference)1 Gather (com.twilio.twiml.voice.Gather)1 Queue (com.twilio.twiml.voice.Queue)1 Redirect (com.twilio.twiml.voice.Redirect)1 Say (com.twilio.twiml.voice.Say)1 URI (java.net.URI)1