Send YouTube video on channel messenger

Hi,

I am working on a feature to send a youtube video as response on messenger channel.

Was trying to create a custom action to do so and could achieve this for web channel by simply using iFrame.

However now I am completely lost about how to do it for messenger. Do I need to create a custom hook or module or action can still be used for this purpose? These are some of the doubts in my mind.

Request some guidance here.

PS: I am using Albert version dated 9th September and completely new to Botpress.

Thanks

Hi @marcmerce, please help to check on this query.

Hi @saurabh,

I’m not technical myself, I’m sorry if my answer is misleading, but have you looked into custom components? I believe Botpress does not currently support Video.


I believe as such the messenger module would need to be extended. @franklevasseur, @allardy or @EFF , can correct me if i’m mistaken.

Thanks
JB

Hi Jean (@jbperron), thanks a lot for your response.

I explored and understood that by default video type is not supported to did a workaround using iFrame and it worked fine for web channel. Attaching a screenshot for reference.

However the same custom action which is passing iFrame component to web channel is not working for messenger channel. If some guidance can be provided to pass an iFrame or Youtube video tag to messenger channel that will be really helpful.

Thanks

Please help with some inputs. Here is my code:

function action(bp: typeof sdk, event: sdk.IO.IncomingEvent, args: any, { user, temp, session } = event.state) {
  /** Your code starts below */

  /**
   * Send video to messenger channel
   * @title FB Video
   * @category Someco
   * @author Someco
   * @param {string} name - An example string variable
   * @param {any} value - Another Example value
   */
  const myAction = async (name, value) => {
    const eventDestination = {
      channel: event.channel,
      target: event.target,
      botId: event.botId,
      threadId: event.threadId
    }

    const payload = await bp.cms.renderElement(
      'builtin_text',
      {
        text:
          '**YouTube video: **\n\n<iframe width="270" height="230" src="https://www.youtube.com/embed/tgbNymZ7vqY"></iframe>',
        markdown: true,
        typing: true
      },
      eventDestination
    )
    await bp.events.replyToEvent(event, payload)
  }

  return myAction(args.name, args.value)

  /** Your code ends here */
}

I am able to get the video rendered on web channel however messenger displays this in plain text. Attaching screenshots for reference.

Hi @saurabh,

Have you tried just sending the url of the video? Won’t it be automatically rendered by messenger?

1 Like