2

I'm working on my framework for Facebook Messenger Platform Send API and I've got this error when trying to create an Airline Itinerary Template (https://developers.facebook.com/docs/messenger-platform/send-api-reference/airline-itinerary-template):

{
 "error": {
   "message": "(#-1) Send API unexpected internal error",
   "type": "OAuthException",
   "code": -1,
   "fbtrace_id": "DBWbw/pHJGv"
 }
}

Here's the request that triggered it:

{  
   "message":{  
      "attachment":{  
         "type":"template",
         "payload":{  
            "flight_info":[  
               {  
                  "connection_id":"123",
                  "segment_id":"123",
                  "aircraft_type":"Boeing",
                  "travel_class":"business",
                  "flight_number":"123",
                  "departure_airport":{  
                     "airport_code":"CT",
                     "city":"Catania",
                     "terminal":"F",
                     "gate":"54"
                  },
                  "arrival_airport":{  
                     "airport_code":"BG",
                     "city":"Bergamo",
                     "terminal":"C",
                     "gate":"12"
                  },
                  "flight_schedule":{  
                     "boarding_time":"2016-8-25T15:8",
                     "departure_time":"2016-8-25T15:8",
                     "arrival_time":"2016-8-25T15:8"
                  }
               }
            ],
            "passenger_info":[  
               {  
                  "passenger_id":"1",
                  "ticket_number":"215",
                  "name":"Sarah Hum"
               },
               {  
                  "passenger_id":"2",
                  "name":"Jeremy Goldberg"
               }
            ],
            "passenger_segment_info":[  
               {  
                  "segment_id":"241",
                  "passenger_id":"251",
                  "seat":"14A",
                  "seat_type":"Economy",
                  "product_info":[  
                     {  
                        "title":"Cabin",
                        "value":"Coach"
                     }
                  ]
               }
            ],
            "price_info":[  
               {  
                  "title":"Cabin",
                  "amount":100.0,
                  "currency":"USD"
               },
               {  
                  "title":"Ticket",
                  "amount":200.0
               }
            ],
            "base_price":200.71,
            "tax":200.0,
            "total_price":4032.54,
            "currency":"USD",
            "pnr_number":"D0FQTK",
            "intro_message":"Here\u0027s your itinerary",
            "locale":"en_US",
            "template_type":"airline_itinerary"
         }
      }
   },
   "recipient":{  
      "id":"************"
   }
}

At this URL: https://graph.facebook.com/v2.7/me/messages?access_token=*******

I've got this problem only with this specific template. The other works just fine. Does anybody know what may be the cause of it?

Thank you.

Aurasphere
  • 3,841
  • 12
  • 44
  • 71
  • 1
    _“unexpected internal error”_ means even the API itself isn’t sure :) File a bug report, so they can look into it: https://developers.facebook.com/bugs (Make sure to mention the fbtrace_id, that helps them find the relevant data quicker.) – CBroe Aug 25 '16 at 14:03
  • 1
    Thank you, I've already done that before posting here. I thought that someone here might have any other info on this. – Aurasphere Aug 25 '16 at 14:16
  • Do you mean in the post? I didn't add any comment before that one and it's not edited... – Aurasphere Aug 25 '16 at 14:21

2 Answers2

1

I have the same problem, did you try with 2.6 API version ?

https://graph.facebook.com/v2.6/me/messages?access_token=*******

I have just try with a CURL request and it works fine with the facebook docs example

curl -X POST -H "Content-Type: application/json" -d '{
"recipient": {
    "id": "XXXX"
},
"message": {
    "attachment": {
        "type": "template",
        "payload": {
            "template_type": "airline_itinerary",
            "intro_message": "Heres 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=xxxxx'
gil13
  • 114
  • 1
  • 10
  • Yep, I did but it still doesn't work. Their example works for sure. There's definetly something wrong in my request (I suspect a conversion from the floating point values into an integer) but the server shouldn't crash like that... I'll test this more in detail as soon as I have some spare time. Meanwhile, the Facebook Messenger Team is checking the bug report. I'll update the post when I have more information. – Aurasphere Aug 25 '16 at 18:21
  • 1
    Im having same problem so its not your fault, Im not having problems with other airlines templates. Lets wait for facebook bugs platform .... – gil13 Aug 25 '16 at 18:27
1

I see the below issues in your message json.

  1. The segment_id in flight_info section isn't matching the one in the passenger_segment_info section
  2. Same issue with the passenger_id field.
  3. The boarding, arrival and departure date format is wrong. You need to prefix 0 if the month, day, hour or minute is single digit.

I tested with the above fixes and it worked fine. Here is the updated example.

{
     "attachment":{  
     "type":"template",
     "payload":{  
        "flight_info":[  
           {  
              "connection_id":"123",
              "segment_id":"241",
              "aircraft_type":"Boeing",
              "travel_class":"business",
              "flight_number":"123",
              "departure_airport":{  
                 "airport_code":"CT",
                 "city":"Catania",
                 "terminal":"F",
                 "gate":"54"
              },
              "arrival_airport":{  
                 "airport_code":"BG",
                 "city":"Bergamo",
                 "terminal":"C",
                 "gate":"12"
              },
              "flight_schedule":{  
                 "boarding_time":"2016-08-25T15:08",
                 "departure_time":"2016-08-25T15:08",
                 "arrival_time":"2016-08-25T15:08"
              }
           }
        ],
        "passenger_info":[  
           {  
              "passenger_id":"1",
              "ticket_number":"215",
              "name":"Sarah Hum"
           },
           {  
              "passenger_id":"2",
              "name":"Jeremy Goldberg"
           }
        ],
        "passenger_segment_info":[  
           {  
              "segment_id":"241",
              "passenger_id":"1",
              "seat":"14A",
              "seat_type":"Economy",
              "product_info":[  
                 {  
                    "title":"Cabin",
                    "value":"Coach"
                 }
              ]
           }
        ],
        "price_info":[  
           {  
              "title":"Cabin",
              "amount":100.0,
              "currency":"USD"
           },
           {  
              "title":"Ticket",
              "amount":200.0
           }
        ],
        "base_price":200.71,
        "tax":200.0,
        "total_price":4032.54,
        "currency":"USD",
        "pnr_number":"D0FQTK",
        "intro_message":"Here\u0027s your itinerary",
        "locale":"en_US",
        "template_type":"airline_itinerary"
     }
  }
},

I hope Facebook will someday update the documentation with the details about these constraints. Please share your bug ticket link here so that we can subscribe to it.

Guru Atlu
  • 61
  • 5
  • Now YOU should work for Facebook. Their documentation is so poor. With your fix the request works just fine. Thank you. Here's the bug ticket: https://developers.facebook.com/bugs/1067679626630796/ – Aurasphere Aug 26 '16 at 21:55