简体   繁体   English

Twilio Flex 中的 CRMContainer 问题

[英]Issue with CRMContainer in Twilio Flex

I built a simple plugin that shows in the CRMContainer the url of my CRM given some attributes parameters (if they are passed by), during inbound tasks this works fine, but the problem is that during outbound calls the behaviour is not the one expected, this is the piece of code:我构建了一个简单的插件,它在 CRMContainer 中显示我的 CRM 的 url 给定一些属性参数(如果它们被传递),在入站任务期间这工作正常,但问题是在出站调用期间行为不是预期的,这是一段代码:

flex.CRMContainer.defaultProps.uriCallback = (task) => {
  return task
 
    ? `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`
    : 'https://mycrm.zzz/contacts/';
  }

} }

I would need an additional condition that tells the code, if this is an outbound voice call to always show a default url. I tried adding an if/else that checks if task.attributes.direction is outbound, but Flex says this is undefined.我需要一个附加条件来告诉代码,如果这是出站语音呼叫,则始终显示默认值 url。我尝试添加一个 if/else 来检查 task.attributes.direction 是否出站,但 Flex 说这是未定义的。 Any tip?任何提示? Thanks谢谢

Max最大限度

The problem is that you aren't checking for the existence of the task .问题是您没有检查task是否存在。 Your original code had this:你的原始代码是这样的:

flex.CRMContainer.defaultProps.uriCallback = (task) => {
  return task
    ? `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`
    : 'https://mycrm.zzz/contacts/';
  }
}

Which returns the URL with the task attributes in it only if the task exists, because of the ternary conditional.由于三元条件,只有当task存在时,它才会返回带有任务属性的 URL。

So, when you try to use the attributes you need to make sure the task exists.因此,当您尝试使用属性时,您需要确保task存在。 So taking your code from the last comment, it should look like this:所以从最后一条评论中获取你的代码,它应该是这样的:

flex.CRMContainer.defaultProps.uriCallback = (task) => {
  if (task) {
    if (task.attributes.direction === 'outbound'){
      return `https://mycrm.zzz/${task.attributes.clicar}/${task.attributes.contacth}/`;
    } else {
      return `https://mycrm.zzz/contacts/`
    }
  } else {
    return 'https://mycrm.zzz/contacts/';
  }
}

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

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