简体   繁体   English

尝试在Flex Twilio中的传入SMS上启用声音

[英]Trying to enable sound on incoming SMS in Flex Twilio

I've set up a workspace in Flex to handle incoming SMS contacts from customers. 我在Flex中设置了一个工作区来处理来自客户的传入SMS联系人。 What I'm trying to do is enable an audio notification that a new SMS message has come into Flex. 我正在尝试做的是启用一个音频通知,告知新的SMS消息已传入Flex。 I'm working on a Flex Plugin to do this. 我正在使用Flex插件来做到这一点。

What I've done is added a listener for a new reservation being created. 我所做的是为创建的新预留添加了一个侦听器。 If a new reservation has been created I'm trying to play an audio file as the notification. 如果创建了新的预订,我将尝试播放音频文件作为通知。 I've enabled error logging but the code is not triggering any errors. 我已启用错误日志记录,但代码未触发任何错误。

    init(flex, manager) {
    let ringer = new Audio("*.mp3");
    ringer.loop = true;

     const resStatus = ["accepted","rejected","rescinded","timeout"];
     manager.workerClient.on("reservationCreated", function(reservation) {
if (reservation.task.taskChannelUniqueName === 'sms') {
  ringer.play()
};
    resStatus.forEach((e) => {
    reservation.on(e, () => {
    ringer.pause()'''

I was expecting the mp3 to play if a new reservation was created with a taskchanneldefinition name of sms. 我期望如果使用taskchanneldefinition sms创建新的保留,则mp3会播放。 New sms messages come into the sms channel. 新的短信消息进入短信频道。 When running on Flex, no sound plays and no errors are being logged. 在Flex上运行时,没有声音播放,也没有记录错误。

try playing sounds outside this method, does it work? 尝试用这种方法之外的声音播放,行得通吗? a few possible problems that you may face: 您可能会遇到的一些可能的问题:

1) new Audio("*.mp3"), do you load a sound here properly? 1)新的Audio(“ *。mp3”),您在此处正确加载声音吗? i think something is wrong with this one 我认为这有问题

if not 如果不

2) you likely need to interact with flex-ui as said herehttps://www.twilio.com/docs/flex/audio-player#troubleshooting 2)您可能需要按照此处所述与flex-ui进行交互https://www.twilio.com/docs/flex/audio-player#troubleshooting

here is an example that i have and it works: 这是我有一个例子,它的工作原理:

manager.chatClient.on("messageAdded", () => {
  //some stuff going on here

   new Audio(NEW_MESSAGE_AUDIO).play();
});

where NEW_MESSAGE_AUDIO is a data:audio/mpeg;base64 file 其中NEW_MESSAGE_AUDIO是data:audio/mpeg;base64文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM