Request URI

https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>

Example Request

curl -X POST -H "Content-Type: application/json" -d '{
  "recipient": {
    "id": "<PSID>"
  },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "airline_update",
        "intro_message": "Your flight is delayed",
        "update_type": "delay",
        "locale": "en_US",
        "pnr_number": "CF23G2",
        "update_flight_info": {
          "flight_number": "KL123",
          "departure_airport": {
            "airport_code": "SFO",
            "city": "San Francisco",
            "terminal": "T4",
            "gate": "G8"
          },
          "arrival_airport": {
            "airport_code": "AMS",
            "city": "Amsterdam",
            "terminal": "T4",
            "gate": "G8"
          },
          "flight_schedule": {
            "boarding_time": "2015-12-26T10:30",
            "departure_time": "2015-12-26T11:30",
            "arrival_time": "2015-12-27T07:30"
          }
        }
      }
    }
  }
}' 'https://graph.facebook.com/v2.6/me/messages?access_token=<PAGE_ACCESS_TOKEN>'

Example Response

{
  "recipient_id": "1254477777772919",
  "message_id": "mid.$cAAJsujCd2ORj_1qmrFdzhVa-4cvO"
}  

Properties

recipient

Description of the message recipient. All requests must include one of id, phone_number, or user_ref.

Property Type Description

recipient.id

String

PSID of the message recipient. Either PSID or phone_number must be set.

recipient.phone_number

String

Optional. Phone number of the recipient with the format +1(212)555-2368.


Your bot must be approved for Customer Matching to send messages this way.

recipient.user_ref

String

Optional. user_ref from the checkbox plugin.

recipient.name

Object

Optional. Used only if phone_number is set. Specifies the person's name in the format:


{"first_name":"John", "last_name":"Doe"}

Providing a name increases the odds of a successful match.

message

Description of the message to be sent.
Property Type Description

message.attachment

Object

An object describing attachments to the message.

message.attachment

Property Type Description

type

String

Value must be template

payload

Object

payload of the template.

message.attachment.payload

Property Name Type Description

template_type

String

Value must be airline_update

intro_message

String

Introduction message

theme_color

String

Optional. Background color of the attachment. Must be a RGB hexadecimal string. Defaults to #009ddc.

update_type

String

Type of update. Must be 'delay', 'gate_change' or 'cancellation'.

locale

String

Two-letter language region code. Must be a two-letter ISO 639-1 language code and a ISO 3166-1 alpha-2 region code separated by an underscore character. Used to translate field labels (e.g. en_US). See this document for more information about Facebook's locale support.

pnr_number

String

Optional. The Passenger Name Record number (Booking Number).

`update_flight_info

String

Updated flight information.

message.attachment.payload.update_flight_info

Property Type Description

flight_number

String

Flight number

departure_airport

Object

Departure airport

arrival_airport

Object

Arrival airport

flight_schedule

Object

Schedule for the flight. See flight_schedule.

message.attachment.payload.boarding_pass.flight_info.flight_schedule

Property Name Type Description

boarding_time

String

Optional. Boarding time in departure airport timezone. Must be in the ISO 8601-based format YYYY-MM-DDThh:mm (e.g. 2015-09-26T10:30).

departure_time

String

Departure time in departure airport timezone. Must be in the ISO 8601-based format YYYY-MM-DDThh:mm (e.g. 2015-09-26T10:30).

arrival_time

String

Optional. Arrival time in arrival airport timezone. Must be in the ISO 8601-based format YYYY-MM-DDThh:mm (e.g. 2015-09-26T10:30).

message.attachment.payload.boarding_pass.flight_info.departure_airport

Property Type Description

airport_code

String

Airport code of the departure airport.

city

String

Departure city of the flight.

terminal

String

Terminal of the departing flight.

gate

String

Gate for the departing flight.

message.attachment.payload.boarding_pass.flight_info.arrival_airport

Property Type Description

airport_code

String

Airport code of the arrival airport.

city

String

Arrival city of the flight.

terminal

String

Terminal of the departing flight.

gate

String

Gate for the departing flight.