How can I retrieve my current twilio phone number and the phone number I am chatting with in flex?
Hello Community,
I have a quick question. I wonder how can I retrieve my Twilio current phone number (the one I use to send messages) and the number I am chatting with (the telephone number I am responding to in flex).
I need to store those values in properties to pass them to a custom component I have created. I
Any help will be great.
Thanks !
Answers
-
Hi there,
Flex uses proxy to coordinate messaging, so you will want to query the proxy participants and look for the identifier.
twilio api:proxy:v1:services:sessions:participants:fetch \ --service-sid KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \ --session-sid KCXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
will return a list of the participants in a particular session.
You can read more about what's available in the documentation located here:
Hope this helps!
-
But for example I am using a custom component created for a flex how can I access the actual task attributes from my component ? I am trying to pass this info as a prop from the main plugin but this does not work.
So I do not know if I can retrieve the task attributes directly from my Custom Component.
-
One way to get task values is by using the Actions Framework.
Actions.addListener(name: string, action: ActionFunction | EventHandler)
The event passes a task object to the handler. This is populated with that agents current Task values.
Actions (Events) https://www.twilio.com/docs/flex/actions-framework#list-of-actions
Attaching a handler (ActionFunction) to an "before" event.
Twilio.Flex.Actions.addListener('beforeTaskAccepted', (task: Task) => { // now you can access your task values here! console.log('New Task:', task); // ...do more stuff with your task!! });
-
Thanks! It has been useful😁