I am currently sending Webhook requests to my email
When I receive it the message is for example: How+are+you%3F
How do I convert the ASCII to normal characters?
Thanks
I am currently sending Webhook requests to my email
When I receive it the message is for example: How+are+you%3F
How do I convert the ASCII to normal characters?
Thanks
Hi @pameladicus
First off, welcome to the Pipedream community. Happy to have you!
This Node.js package might help you: html-entities - npm
You can import it into a Node.js code step in Pipedream and decode the HTML encoded string.
But, you may also find luck in using the steps.trigger.event.query
object instead, which may already decode these values passed by the query string.
Hope this helps!
@pierce
Thanks for your help but I can’t seem to import that Node.js package, I keep getting an error. When I use steps.trigger.event.query the + in between the words still show.
Hi @pameladicus
Could you share your Node.js code you’re attempting to run in a code step? Perhaps there’s a clue there we can troubleshoot.
@pierce I updated the code that I want to use but it still doesn’t work
const { encode, decode } = require('url-encode-decode')
decode (steps.trigger.event.Message)
I want to decode (steps.trigger.event.Message) from the previous step and pass the decoded message to the next step
I am trying to decode the URL encoded string
I want to use Url-encode-decode NPM | npm.io to decode steps.trigger.event.Message
@pierce I updated the code that I want to use but it still doesn’t work
const { encode, decode } = require('url-encode-decode') decode (steps.trigger.event.Message)
I want to decode (steps.trigger.event.Message) from the previous step and pass the decoded message to the next step
Hi @pameladicus, I believe the issue with your code above is that the defineComponent
scaffolding was removed. That needs to be in place for the Node.js step to function properly.
Here’s a quick video that shows how a Node.js step works. I encourage you to watch it.
Here’s an example Node.js code step to accept a string
property, which you can pass your steps.trigger.event.Message
into.
It will decode the query string parameter and output normal characters. Hope this helps!
import querystring from 'query-string';
// To use previous step data, pass the `steps` object to the run() function
export default defineComponent({
props: {
string: {
type: "string",
label: "String",
description: "HTML encoded string to be converted",
},
},
async run({ steps, $ }) {
const parsedObj = querystring.parse(this.string);
const value = Object.keys(parsedObj)[0];
return value;
},
})
@pierce I have watched the video and I am still learning to fully understand the code but it’s now working.
Thanks for your help
Hi @pameladicus of course happy to help
Here’s a list of resources to get started with learning Javascript:
The Eloquent guide to Javascript is personally how I learned and I think it’s the most approachable.
Best of luck!