Skip to content

Instantly share code, notes, and snippets.

@mjg123
Created March 25, 2020 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjg123/e42c5e797b389d6a7c1ad7b016f1519f to your computer and use it in GitHub Desktop.
Save mjg123/e42c5e797b389d6a7c1ad7b016f1519f to your computer and use it in GitHub Desktop.
Spring Web controller that produces TwiML for creating a conference call
package lol.gilliard.conferencecalls;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Conference;
import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.voice.Say;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class IncomingCallWebhook {
private static String CONFERENCE_ROOM_NAME = "my-conference-room";
@PostMapping(value = "/call", produces = "text/xml")
@ResponseBody
public String generateTwiml(){
return new VoiceResponse.Builder()
.say(new Say.Builder("Hold tight, we're connecting you to the conference call").build())
.dial(new Dial.Builder()
.conference(new Conference.Builder(CONFERENCE_ROOM_NAME).build())
.build())
.build().toXml();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment