I don't know Java Script. But I'm trying to learn in order to make this work.
The Goal: TO create a scheduled sms notification after a sms has been received.
The code appears to be created by js07 on github:
https://github.com/PipedreamHQ/pipedream/blob/master/components/twilio/actions/send-sms/send-sms.mjs
Here's the code of the app I'm using on pipe dreams:
// Read the Twilio docs at https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource
import twilio from "../../twilio.app.mjs";
import { phone } from "phone";
export default {
key: "twilio-send-sms",
name: "Send SMS",
description: "Send a simple text-only SMS. [See the docs](https://www.twilio.com/docs/sms/api/message-resource#create-a-message-resource) for more information",
type: "action",
version: "0.0.6",
props: {
twilio,
from: {
propDefinition: [
twilio,
"from",
],
},
to: {
propDefinition: [
twilio,
"to",
],
},
body: {
propDefinition: [
twilio,
"body",
],
},
},
async run({ $ }) {
// Parse the given number into its E.164 equivalent
// The E.164 phone number will be included in the first element
// of the array, but the array will be empty if parsing fails.
// See https://www.npmjs.com/package/phone
const toParsed = phone(this.to);
if (!toParsed || !toParsed.phoneNumber) {
throw new Error(`Phone number ${this.to} couldn't be parsed as a valid number.`);
}
const data = {
to: toParsed.phoneNumber,
from: this.from,
body: this.body,
};
const resp = await this.twilio.getClient().messages.create(data);
$.export("$summary", `Successfully sent a new SMS, "${this.twilio.messageToString(resp)}"`);
return resp;
},
};