I’d like to trigger on receipt of a webhook from Plex and send a message to Pushover, dependent upon type of payload received (as define in the payload) and using some of data fields from the payload. Programming newbie I can’t determine how to access and examine/use the payload data once triggered.
Hi @dean,
You can achieve this by creating a Pipedream workflow with an HTTP trigger to receive the webhook from Plex and then use a code step to process the payload and send a message to Pushover based on the payload data. Here’s a step-by-step guide:
- Create a new workflow in Pipedream.
- Add an HTTP trigger to receive the webhook from Plex.
- Add a code step to process the payload and send a message to Pushover.
Here’s the complete code for the code step:
import { axios } from "@pipedream/platform";
export default defineComponent({
props: {
pushover: {
type: "app",
app: "pushover",
},
},
async run({ steps, $ }) {
// Access the payload from the HTTP trigger
const payload = steps.trigger.event.body;
// Define the conditions to send a message to Pushover
if (payload.event === "media.play" && payload.Metadata.type === "movie") {
const message = `A movie is being played: ${payload.Metadata.title}`;
// Send a message to Pushover
return await axios($, {
method: "post",
url: `https://api.pushover.net/1/messages.json`,
params: {
token: `${this.pushover.$auth.api_token}`,
user: `${this.pushover.$auth.user_key}`,
message: message,
},
});
} else {
return "No action taken";
}
},
});
Explanation:
-
HTTP Trigger: This step will receive the webhook from Plex. The payload will be available in
steps.trigger.event.body
. -
Code Step: This step processes the payload and sends a message to Pushover if the conditions are met.
- The
payload
variable contains the data received from the Plex webhook. - The
if
statement checks if the event ismedia.play
and the type ismovie
. - If the conditions are met, a message is constructed and sent to Pushover using the
axios
library.
- The
Using the Pushover App (trigger|action)
- Search for the Pushover app from the step menu.
- Select the Push Notification action.
- Connect your Pushover account.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double-check my answers and code! Learn how to build your own.