twiliotwilio-flex

How can I retrieve phone number of caller in Twilio Flex?


I am trying to retrieve caller phone number in the Flex plug-in. Using the caller phone number, I need to change the URI of the CRMContainer.

I have tried following methods but can't find caller phone number.

First method: function parameter task does not have caller phone number.

flex.CRMContainer.defaultProps.uriCallback  = task => {
  if (!task) {
    return 'http://localhost:4000'
  }

  return 'http://localhost:4000/searchresults?type=ALL&status=ANY&phoneNumber=(213)777-8888&query='

}

Second method: function parameter payload does not have caller phone number.

flex.Actions.addListener("beforeAcceptTask", payload => {
  flex.CRMContainer.defaultProps.uri = 'http://localhost:4000/searchresults?type=ALL&status=ANY&phoneNumber=(213)777-8888&query='
});

Third method: function parameter conn does not have caller phone number.

    manager.voiceClient.
    addListener('incoming', conn => {
      flex.CRMContainer.uri  =  'http://localhost:4000/searchresults?type=ALL&status=ANY&phoneNumber=(213)777-8888&query='
  })

Any help is appreciated.

Thanks


Solution

  • Did you trying looking at the payload:

    payload.task.attributes specifically:

    payload.task.attributes.from ?