Post new YouTube video from selected channel to Discord text channel

Hi,

I’ve been playing around with a few different platforms, triggering webhooks.

On another platform I’m able to setup a YouTube trigger that gets the newest video
from any channel, then post that in a Discord text channel, the results include a link
to the YouTube video and the Discord post displays the video instead of just the link.

Here’s an example

What I did was, create a trigger for YouTube to get a new video from a selected channel ID.

Method: Post
Type JSON/Application

Then I created an action for discord webhook,

I’m not sure what to put in the message box in PipeDream, maybe the setup is different.

{ “username”:“DnB News {{PublishedAt}}”, “avatar_url”:“https://cdn.discordapp.com/avatars/939690179776610415/370be74ecac72e2662aaf4d4276ed106.webp?size=80”, “content”:“New Release: {{Title}}: {{Url}}” }

That gets the YouTube video from channel ID, and posted to the discord text channel I set.

Thanks in advance!

Hi @EMar , welcome to the Pipedream community, happy to have you!

This is really neat, I’m a big UKF / d&b fan myself too.

So for example if your webhook payload includes { title: 'Netsky - I Choose You', url: 'https://www.youtube.com/watch?v=qhFN5D_nRcA' }, then you an reference that data within the Discord Webhook Message action like this:

In the Message field:

New Release: {{ steps.trigger.event.title }} : {{ steps.trigger.event.url }}

Forgive my ignorance of Discord just a bit, I’m more of a Slack user.

But looking at the available options in the Discord Webhook actions, it looks like you’ll be able to pass the video information from the body of the webhook into the embeds property on the Discord Webhooks send message (advanced) action Pipedream provides:

You would just need to follow the format of embeds they document here:
Discord Webhook Embeds docs

Hope this helps! Happy jamming.

Hi Pierce,

I’m not sure what the difference is between the message field and embeds field.

This is what I tried in the message field,
Not sure how to get the YouTube video to display when it posts in Discord text channel.

When I click Send Test Event, it sends this to the Discord text channel

The fact that it’s sending the YouTube post to Discord means it’s working at least?

The good news is that Discord is smart enough to render a YouTube embed without any special embed notation. So you can ignore my comment about that part of their API.

All the workflow needs to do is place the YouTube link as a message, Discord figures out the rest:

From that last screenshot you shared, it looks like you’re attempting to access the video URL at:

{{ steps.trigger.event.video.url }}

The TypeError you’re seeing is because the steps.trigger.event.video property doesn’t exist.

I saw in a different screenshot you shared, that you were referencing this property:

{{ event.snippet.url }}

Does the YouTube link exist on that path? Can you try it in the Message box?

Do you mean test it like this, in the message field:

Send Test Event does post it to the Discord channel, but not the video,

Not sure what you mean about the the youtube existing in the path,
The trigger I used just asks for the youtube channel ID

@EMar exactly. You’re right there.

So the title and published date worked correctly because you referenced the full path to those variables:

{{ steps.trigger.event.snippet.publishTime }}
{{ steps.trigger.event.snippet.title }}

However, with the final line that should contain the YouTube video link, it needs to use the full path like the other to. Currently it is:

{{ event.snippet.url }}

But, the YouTube video URL is part of the steps.trigger event:

{{ steps.trigger.event.snippet.url }}

I tried that too but no luck,
It does post it to the discord channel webhook, but the youtube video is still missing.

  1. Published Date: 2022-02-16T13:00:15Z
    Release: ARRATOU - Stay
    YouTube URL: undefined

Hi @EMar ,

Perhaps the URL is at a different path and not at snippet.url? Can you perhaps share the output from your YouTube trigger step?

I haven’t a clue tbh, how do I share the trigger steps?

steps.

trigger

Listening for new events

you-tube-latest-video-from-channel-id

name slug:

you-tube-latest-video-from-channel-id

status:

active

type:

timer

edit code and configuration

test

steps.trigger.context{12}

deployment_id:d_rNsAJj2

hops:null

id:25FgaVw3LjPAR1Eum4bdjslp2Be

owner_id:u_7bhgEDo

pipeline_id:null

platform_version:3.20.2

resume:null

source_type:SDK

ts:2022-02-17T20:05:11.544Z

verified:false

workflow_id:p_5VCl1rP

workflow_name:Minimal & Techno

steps.trigger.event{4}

etag:mb9LIFIiq4wn6Q5_ZZVVOUkjBOw

id{2}

kind:youtube#video

videoId:e92gnaycQN8

kind:youtube#searchResult

snippet{8}

channelId:UCrcfRtdHb11YJEloTSaOYvw

channelTitle:Dark Monkey Music

description

Prevision - Reality (Digital Pulse Remix) Spotify Playlist: https://linktr.ee/trippyspotifyplaylist ⚫️ | Follow Dark Monkey Music ...

liveBroadcastContent:none

publishTime:2022-02-17T13:00:18Z

publishedAt:2022-02-17T13:00:18Z

thumbnails{3}

default{3}

high{3}

medium{3}

title:Prevision - Reality (Digital Pulse Remix)

steps.trigger.pd_event_type:test

steps.trigger.raw_event{4}

etag:mb9LIFIiq4wn6Q5_ZZVVOUkjBOw

id{2}

kind:youtube#video

videoId:e92gnaycQN8

kind:youtube#searchResult

snippet{8}

channelId:UCrcfRtdHb11YJEloTSaOYvw

channelTitle:Dark Monkey Music

descriptionPrevision - Reality (Digital Pulse Remix) Spotify Playlist: Spotify Playlist | Linktree :black_circle: | Follow Dark Monkey Music …

liveBroadcastContent:none

publishTime:2022-02-17T13:00:18Z

publishedAt:2022-02-17T13:00:18Z

thumbnails{3}

title:Prevision - Reality (Digital Pulse Remix)

Hi @EMar

You can share workflows with support under the Settings area of the workflow.

But I believe I see the problem. We were both expecting that a URL would be available in the data from the YouTube trigger.

However, there isn’t one at all.

The closest data point they give you is the Video ID.

However, you can still use this ID to construct the YouTube URL:

https://youtube.com/watch?v={{ steps.trigger.event.id.videoId }}

That should link to the video on YouTube and Discord will be able to show a preview of it in your message.

Hi Pierce,

I enabled “Allow Pipedream Support to access or edit this workflow” on the workflow.

Not sure I follow you about the url part,
I added it to the message body field, for the Discord action.

Published: {{steps.trigger.event.snippet.publishTime}}
Release: {{steps.trigger.event.snippet.title}}
https ://youtube.com/watch?v={{steps.trigger.event.snippet.url}}

Here’s what it posts to Discord:

I got it!

I had to change the code to
h ttps://youtube.com/watch?v={{steps.trigger.raw_event.id.videoId}}

Hi @EMar

I was referring to what to enter in your message.

Here’s what you have currently:

Published: {{steps.trigger.event.snippet.publishTime}}
Release: {{steps.trigger.event.snippet.title}}
https://youtube.com/watch?v={{steps.trigger.event.snippet.url}}

The problem is with the end there: {{ steps.trigger.event.snippet.url }} does not exist unfortunately, that’s why you’re seeing https://youtube.com/watch?v=undefined. undefined means there’s no data at that path.

The end goal is to create a valid YouTube link, that looks like this: https://youtube.com/watch?/v=<The new video ID from the trigger step here>

The video ID is exposed at this location: steps.trigger.event.id.videoId

So in the end we want:

Published: {{steps.trigger.event.snippet.publishTime}}
Release: {{steps.trigger.event.snippet.title}}
https://youtube.com/watch?v={{steps.trigger.event.id.videoId}}

Cool thanks a lot for the tips, you got me going!

Great, glad it’s working for you now :slight_smile: