Created
March 25, 2020 10:26
-
-
Save mjg123/e42c5e797b389d6a7c1ad7b016f1519f to your computer and use it in GitHub Desktop.
Spring Web controller that produces TwiML for creating a conference call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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