PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 12, 2022

[FIXED] How to set a welcome message for my Messenger Bot

 July 12, 2022     bots, facebook, message, messenger     No comments   

Issue

I am trying to create a simple answer bot fo my facebook page but am kind of lost as it it my first try.

I have integrated the webhook on my website and this is the file at the end of my Callback URL:

<?php 
$challenge = $_REQUEST['hub_challenge'];
$verify_token = $_REQUEST['hub_verify_token'];

if ($verify_token === 'YOURVERIFYTOKEN'){
echo $challenge;
}
?>

The webhook is set up but I have no clue what should be my next step ? How could I set up a welcome message ?


Solution

You're meant to be able to do it by posting to this API:

https://developers.facebook.com/docs/messenger-platform/send-api-reference#welcome_message_configuration

https://graph.facebook.com/v2.6/<PAGE_ID>/thread_settings?access_token=<PAGE_ACCESS_TOKEN>

with a payload like this:

{
  "setting_type":"call_to_actions",
  "thread_state":"new_thread",
  "call_to_actions":[
    {
      "message":{
        "text":"Welcome to My Company!"
      }
    }
  ]
}

This has worked for me in the past but I'm currently getting validation errors when I try. I've opened a bug with the facebook platform team.

Update

To set a welcome message you send the following payload to the above URL:

{
  "setting_type":"greeting",
  "greeting":{
    "text":"Timeless apparel for the masses."
  }
}

as per:

https://developers.facebook.com/docs/messenger-platform/thread-settings/greeting-text



Answered By - Kai G
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing