Twilio TaskRouter.js 更新 activity 或保留导致错误 403(定义的策略使我们无法访问给定资源)

Twilio TaskRouter.js update activity or reservation causes an error 403 (Policies defined such that we cannot access the given resource)

我正在按照这里的指南 https://www.twilio.com/docs/taskrouter/quickstart/ruby/agent-ui-add-project 更新 activity 或预订状态时遇到问题。

这是浏览器控制台上记录的完整错误VM272:1 POST https://event-bridge.twilio.com/v1/wschannels/AC509cc0d468c2924356d7f1f071254995/WK01bf75406b9b5bd6f56711507289386d 403 (Policies defined such that we cannot access the given resource)

在我的控制器中,活动和预订的政策是这样定义的

    allow_activity_updates = Twilio::JWT::TaskRouterCapability::Policy.new(
      Twilio::JWT::TaskRouterCapability::TaskRouterUtils
      .all_activities(workspace_sid), 'POST', true
    )
    capability.add_policy(allow_activity_updates)

    allow_reservation_updates = Twilio::JWT::TaskRouterCapability::Policy.new(
      Twilio::JWT::TaskRouterCapability::TaskRouterUtils
      .all_reservations(workspace_sid, worker_sid), 'POST', true
    )
    capability.add_policy(allow_reservation_updates)

Javascript部分

worker.update({"ActivitySid":nextActivitySid}, function(error, worker) {
                      if(error) {
                        console.log(error.code);
                        console.log(error.message);
                      } else {
                        console.log(worker.activityName); // "Offline"
                      }
                    });

activity 和预订侦听器运行良好,就在我需要更新时出现问题。

Twilio 的支持现已解决此问题。解决方案是文档中不存在的缺失功能。

allow_worker_update = Twilio::JWT::TaskRouterCapability::Policy.new(
  Twilio::JWT::TaskRouterCapability::TaskRouterUtils
  .worker(workspace_sid, worker_sid), 'POST', true
)
capability.add_policy(allow_worker_update)