Uraforclain
Uraforclain

Reputation: 365

How to add a hyperlink in fb messenger

I'm trying to add a hyperlink in fb messenger. Basically I'm creating a chatbot that replies users questions. However when I want to link the user to a webpage the only way possible is if I type in the whole URL which is really lengthy and ugly.

Fb messenger does not support HTML tags so I can't use the anchor tag to create a hyperlink for my URL to hide the link behind a word..

Is there a way I can type a sentence and hyperlink the URL behind a word in fb messenger?

Been searching tooo long now..

Upvotes: 1

Views: 20331

Answers (1)

amuramoto
amuramoto

Reputation: 2848

You can use a generic template with a web_url and no image:

{
  "recipient":{
    "id":"333333333"
  },
  "message":{
    "attachment":{
      "type":"template",
      "payload":{
        "template_type":"generic",
        "elements":[
           {
            "title":"Here is the link you asked for",
             "default_action": {
              "type": "web_url",
              "url": "https://www.facebook.com",
              "messenger_extensions": true,
              "fallback_url": "https://www.facebook.com/"
            },
            "buttons":[
              {
                "type":"web_url",
                "title": "open link",
                "url":"https://www.facebook.com"
              }              
            ]      
          }
        ]
      }
    }
  }
}

Upvotes: 0

Related Questions