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": "<USER_ID>"
  },
  "message": {
    "attachment": {
      "type": "template",
      "payload": {
        "template_type": "airline_itinerary",
        "intro_message": "Here is your flight itinerary.",
        "locale": "en_US",
        "pnr_number": "ABCDEF",
        "passenger_info": [
          {
            "name": "Farbound Smith Jr",
            "ticket_number": "0741234567890",
            "passenger_id": "p001"
          },
          {
            "name": "Nick Jones",
            "ticket_number": "0741234567891",
            "passenger_id": "p002"
          }
        ],
        "flight_info": [
          {
            "connection_id": "c001",
            "segment_id": "s001",
            "flight_number": "KL9123",
            "aircraft_type": "Boeing 737",
            "departure_airport": {
              "airport_code": "SFO",
              "city": "San Francisco",
              "terminal": "T4",
              "gate": "G8"
            },
            "arrival_airport": {
              "airport_code": "SLC",
              "city": "Salt Lake City",
              "terminal": "T4",
              "gate": "G8"
            },
            "flight_schedule": {
              "departure_time": "2016-01-02T19:45",
              "arrival_time": "2016-01-02T21:20"
            },
            "travel_class": "business"
          },
          {
            "connection_id": "c002",
            "segment_id": "s002",
            "flight_number": "KL321",
            "aircraft_type": "Boeing 747-200",
            "travel_class": "business",
            "departure_airport": {
              "airport_code": "SLC",
              "city": "Salt Lake City",
              "terminal": "T1",
              "gate": "G33"
            },
            "arrival_airport": {
              "airport_code": "AMS",
              "city": "Amsterdam",
              "terminal": "T1",
              "gate": "G33"
            },
            "flight_schedule": {
              "departure_time": "2016-01-02T22:45",
              "arrival_time": "2016-01-03T17:20"
            }
          }
        ],
        "passenger_segment_info": [
          {
            "segment_id": "s001",
            "passenger_id": "p001",
            "seat": "12A",
            "seat_type": "Business"
          },
          {
            "segment_id": "s001",
            "passenger_id": "p002",
            "seat": "12B",
            "seat_type": "Business"
          },
          {
            "segment_id": "s002",
            "passenger_id": "p001",
            "seat": "73A",
            "seat_type": "World Business",
            "product_info": [
              {
                "title": "Lounge",
                "value": "Complimentary lounge access"
              },
              {
                "title": "Baggage",
                "value": "1 extra bag 50lbs"
              }
            ]
          },
          {
            "segment_id": "s002",
            "passenger_id": "p002",
            "seat": "73B",
            "seat_type": "World Business",
            "product_info": [
              {
                "title": "Lounge",
                "value": "Complimentary lounge access"
              },
              {
                "title": "Baggage",
                "value": "1 extra bag 50lbs"
              }
            ]
          }
        ],
        "price_info": [
          {
            "title": "Fuel surcharge",
            "amount": "1597",
            "currency": "USD"
          }
        ],
        "base_price": "12206",
        "tax": "200",
        "total_price": "14003",
        "currency": "USD"
      }
    }
  }
}' '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 Type Description

template_type

String

Value must be airline_itinerary

intro_message

String

Introduction message

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.

theme_color

String

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

pnr_number

String

Passenger name record number (Booking Number)

passenger_info

Array<passenger_info>

Information about a passenger

flight_info

Array<flight_info>

Information about a flight

passenger_segment_info

Array<passenger_segment_info>

Information unique to passenger/segment pair

price_info

Array<price_info>

Optional. Itemization of the total price. Maximum of 4 items is supported.

base_price

Number

Optional. Base price amount

tax

Number

Optional. Tax amount.

total_price

Number

Total price for the booking

currency

String

Pricing currency. Must be a three digit ISO-4217-3 code. See this document for more information about Facebook's currency support.

message.attachment.payload.passenger_info

Property Type Description

passenger_id

String

Passenger ID. Must be unique within the itinerary.

ticket_number

String

Optional. Ticket number.

name

String

Full name of passenger, including title

message.attachment.payload.flight_info

Property Type Description

connection_id

String

Used to group segments of a connection together. Must be unique within the itinerary

segment_id

String

segment_id of passenger_segment_info object

flight_number

String

Flight number

aircraft_type

String

Optional. Aircraft type (e.g. Boing 787).

departure_airport

Object

Departure airport. See departure_airport.

arrival_airport

Object

Arrival airport. See arrival_airport.

flight_schedule

Object

Schedule for the flight. See flight_schedule.

travel_class

String

Travel class. Must be 'economy', 'business' or 'first_class'.

message.attachment.payload.flight_info.flight_schedule

Property 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

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.flight_info.departure_airport

Property Type Description

airport_code

String

Airport code (e.g. SFO)

city

String

City name

terminal

String

Optional. Terminal number.

gate

String

Optional. Gate number.

message.attachment.payload.flight_info.arrival_airport

Property Type Description

airport_code

String

Airport code (e.g. SFO)

city

String

City name

terminal

String

Optional. Terminal number.

gate

String

Optional. Gate number.

message.attachment.payload.passenger_segment_info

Property Type Description

segment_id

String

Used to identify a flight segment. Must be unique within the itinerary.

passenger_id

String

passenger_id of passenger_info object

seat

String

Seat number for the passenger

seat_type

String

Seat type for the passenger (e.g. Economy comfort)

product_info

String

Optional. List of products the passenger purchased. Maximum of 4 items is supported.

message.attachment.payload.passenger_segment_info.product_info

Property Type Description

title

String

Product title

value

String

Product description

price_info object

Property Type Description

title

String

Price info title

amount

Number

Price amount

currency

String

Optional. Pricing currency. Must be a three digit ISO-4217-3 code. See this document for more information about Facebook's currency support.