2

I'm currently using Twilio Flex for my work, and I set up a custom hold music as per these instructions: https://support.twilio.com/hc/en-us/articles/360024055153-Change-the-Hold-Music-with-Twilio-Flex#h_031b6c4b-32cd-4c15-a50b-cc6e9685b3ae

It works fine when the user initially calls, but when an agent sets them on hold, it plays the default music. I tried to write a plugin that would replace the music on HoldCall, but it simply does not work. Help? Ideas?

init(flex, manager) {
this.registerReducers(manager);

flex.Actions.replaceAction(
  "HoldCall",
  (payload, original) => {
    return new Promise((resolve, reject) => {
      resolve();
    }).then(() => original(payload));
  },
  "https://handler.twilio.com/twiml/EH994450acfdcfea4b1f097ed2367d4e94"
);}
Walter10h
  • 29
  • 7

1 Answers1

2

You can do like below to get it working Make sure you create twimil first and use that url

You twimil will contain your hold music...

    <?xml version="1.0" encoding="UTF-8"?>
    <Response>
    <Play>http://demo.twilio.com/docs/classic.mp3</Play>
    </Response>

   flex.Actions.replaceAction("HoldCall", (payload, original) => {
         alert("ON HOLD");
         return new Promise((resolve, reject) => {
           resolve();
         }).then(() => {
           original({
             ...payload,
             holdMusicUrl: "https://handler.twilio.com/twiml/EH68cc31b0a9c96616cb877ee471169c60", // your twimil url
             holdMusicMethod: "POST",
           });
         });
       });
Parse Shyam
  • 366
  • 2
  • 14
  • This is the right answer. Following the documentation at https://support.twilio.com/hc/en-us/articles/360024055153-Change-the-Hold-Music-with-Twilio-Flex regarding putting the XML into a TwiML bin and pointing the `holdMusicUrl` at the URL given by TwiML bin works. Returning a promise does not appear to be necessary, just calling `original` should do the trick. There does not appear to be a back-end way to override the hold music (i.e. there does not appear to be a TaskRouter or call status event emitted when an agent puts a caller on hold). – Chris Knepper Aug 05 '21 at 20:54