Twilio-向呼叫者播放录音,将呼叫转接,然后将耳语传递给被呼叫者

时间:2020-08-12 23:58:35

标签: twilio

我需要创建一个执行以下操作的Twimlbin(或一组Twimlbins):

  1. 呼叫者拨打电话时,它会播放录音(我拥有托管的MP3文件的URL)
  2. 将呼叫转接到号码
  3. 在连接呼叫之前先向被叫方耳语。

任何可以帮助的人都会很棒。

谢谢!

1 个答案:

答案 0 :(得分:0)

       In the webhook URL call the callee using following code

     conferenceBuilder = new Conference.Builder(fiendlyname);
                conferenceBuilder.statusCallback("your domain here/your callback hanndling url");
                conferenceBuilder.statusCallbackMethod(HttpMethod.POST);
                conferenceBuilder.statusCallbackEvents(Arrays.asList(Event.START,
                        Event.END, Event.JOIN, Event.LEAVE,
                        Event.MUTE, Event.SPEAKER));
                    say_message = "Whisper message here";
                    conferenceBuilder.endConferenceOnExit(true);
                    conferenceBuilder.waitUrl(waitRingTone); //mp3 file URL to play
                //record call if you want        
                Record record = Record.RECORD_FROM_START;
                conferenceBuilder.record(record);
                
                voiceResponse = new VoiceResponse.Builder()
                .say(new Say.Builder(say_message).voice(Say.Voice.ALICE).build())
                .dial(new Dial.Builder().conference(conferenceBuilder.build()).build())
                .build().toXml();
            return voiceResponse;

Call Using following code : 
    CallCreator callCreator = new CallCreator(new PhoneNumber(calleeNumber), new PhoneNumber(twilioNumber), new URI(buildConferenceUrl(friendlyName)));
            callCreator.setStatusCallback(your domain name here +" url to handle status callback of call");
            callCreator.setMethod(HttpMethod.POST);
            callCreator.setStatusCallbackEvent(Arrays.asList("initiated", "ringing", "answered", "completed"));
                callCreator.setMachineDetection("Enable");
            callCreator.create(restClient);

Return voiceresponse to callee in buildconferenceurl method with say verb