Using When a HTTP request form Twillio which is triggered when an SMS is received, I want to extract the content of the SMS, from number, message content etc. The below screenshot is as far as I have got, how to I extract the content? Ultimately I am wanting to push this information in an email for example
Solved! Go to Solution.
Not a problem, @Blaired79, this is why I pasted the codes into my previous responses, above, in the code boxes.
If you use as expressions (for example, with 'key' in the Switch) it should work.
I'll reword them slightly to make that clearer.
You need to add a Parse JSON step that uses your trigger output as the input, and then you hit the button called "Generate from sample" and paste in your json response (one time) as the example. This will convert your JSON input to an array that you can use downstream in other steps.
Power Automate Flow How to: Parse JSON - YouTube
Pat
To learn more about the Power Platform, follow me on Twitter or subscribe on YouTube.
@Blaired79 what would really help us out would be if you could put a screen shot of your flow (blank our sensitive data) in the original post for this thread.
Also, I've done this previously, and remember it's a bit of toil and trouble.
@mahoneypat, I didn't want to say anything, but I remember Twilio being a right pain, the SMS data is buried in an array of data. Whilst Adding the Parse JSON will help, it might not obviously result in the data for Blaired, but I do think it's a valid solution.
Piecemeal Solution
@Blaired79 , without seeing your flow, you can try this. Assuming that your Twilio instance is firing at an HTTP trigger in flow, then place a Filter action after it, like so:
From:
@triggerBody()?['$formdata']
Condition:
@or(equals(item()?['key'], 'From'),equals(item()?['key'], 'Body'))
Getting the Data From The Filter
After this, I would unfortunately need my flow to be working (it isn't, because my Twilio lapsed) to get the rest. This said, looking at my old flow, I think each array entry is a part of the text data, there are more elegant ways to do this, but I made this before I knew them ... also ... will need to see your flow to apply the elegance anyway. 😉
Either way, run an Apply to each action, which should run twice for the two matching entries that the Filter actions creates.
Inside that, place a Switch action, that runs on the 'key' key (😩) value, and make two cases:
After this Apply to each has run (which should be swift) then you'll have the values you need.
Thanks @eliotcole Twilio is a right pain as I have discovered the output isn't what Parse JSON and I get this error
Below is what I have created so far and I've added your filter, which gives me the SMS body and the sending number.
How do I turn these values into a variable that I can put in an email etc?
I tried recreating your Power Automate but I did not have the 'key' value to use in the switch condition.
It's all good, @Blaired79. 🙂
((( if you look at my flow, you can see that the Switch is inside the Apply to each which runs on the Body from the Filter action )))
You just need to run an Apply to each on the Filter body, that is where you can then take the values. 👍
If your Apply to each is literally called 'Apply to each' then using the following expression in the Switch 'On' field, will get the 'key':
On:
items('Apply_to_each')?['key']
Similarly, when defining either smsMsgVAR or smsFromNumVAR then use this expression to get the 'value':
items('Apply_to_each')?['value']
This just means that the expression looks at the current item in the loop, and in particular the 'value' field. Once you've run it once, Flow should automatically just label them key and value. 🙂
If this is your first time using expressions, just look at the two tabs on the pop up, you have Dynamic content, and Expression. Choose 'Expression' and enter the function in there. 🏆
Hi @eliotcole, thanks for replying so quickly. It's the apply to each area that I am having issues with.
I've been trying to read the text for your formulas in your apply to each and switch but the image pixelates. I think the sticking point for me the is getting key in the switch condition.
Not a problem, @Blaired79, this is why I pasted the codes into my previous responses, above, in the code boxes.
If you use as expressions (for example, with 'key' in the Switch) it should work.
I'll reword them slightly to make that clearer.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
32 | |
32 | |
24 | |
24 | |
21 |
User | Count |
---|---|
64 | |
57 | |
43 | |
37 | |
28 |