API Reference

Tài liệu Pancake API

Get Conversations

GET https://pages.fm/api/v1/pages/[:page_id]/conversations

Dùng để lấy danh sách hội thoại của

Query Parameters

NameTypeDescription

access_token

string

Chuỗi token của khách hàng cung cấp từ Pancake

tags

string

Cần đặt mặc định giá trị "ALL" để lấy hội thoại được gắn tất cả các thẻ hội thoại.

current_count

number

Trường này khi để trống hệ thống sẽ mặc định lấy về 60 hội thoại được tương tác gần hiện tại nhất. Khi thêm giá trị cho `current_count` hệ thống sẽ lấy 40 hội thoại tiếp theo từ vị trí đó trở về quá khứ. VD: current_count = 61. hệ thống sẽ trả về hội thoại có vị trí từ 61 đến 100

Headers

NameTypeDescription

page_id

string

ID của trang bạn muốn lấy dữ liệu

{
    success: true,
    conversations: [
        {
            assignee_group_id: null
            assignee_ids: ["77aa4b50-448b-4b42-871b-ecc7f2c900", "fbe1d782-6e8c-44cc-969c-12b168f194",…]
            customers: [{fb_id: "986800524769491", id: "68f562a-7cc8-4d06-97c3-5968113e65d5", name: "Lê Anh Tuấn"}]
            from: {id: "986800524769491", name: "Lê Anh Tuấn"}
            from_psid: null
            has_phone: false
            id: "1546933003798392_1548442558647439"
            inserted_at: "2020-03-27T03:44:04"
            is_combined: false
            is_removed: false
            last_customer_interactive_at: null
            last_sent_by: {id: "986800524769491", name: "Lê Anh Tuấn"}
            message_count: 1
            page_id: "256465573172082"
            read_watermarks: null
            recent_phone_numbers: []
            recent_seen_users: [{fb_id: "1153161044694652", fb_name: "Lê Anh Tuấn", seen_at: "2020-03-27T03:44:08.120751"}]
            seen: true
            snippet: "Clonners"
            tags: []
            thread_id: null
            thread_key: null
            type: "COMMENT"
            unread_count: 0
            updated_at: "2020-03-27T03:43:57"
        }, {
            .......
        }
    ]
}

Send comment

POST https://pages.fm/api/v1/pages/[:page_id]/conversations/[:coversation_id]/messages?access_token=[:access_token]

Dùng để gửi trả lời bình luận

Query Parameters

NameTypeDescription

access_token

string

Chuỗi token của khách hàng cung cấp từ Pancake

Headers

NameTypeDescription

coversation_id

string

ID hội thoại muốn trả lời

page_id

string

ID trang của bạn

Request Body

NameTypeDescription

message

string

Nội dung bình luận

parent_id

string

ID bình luận muốn trả lời

action

string

Để gửi bình luận cần đặt giá trị reply_comment

{
    "id": "1599241350234224_1599318880226471",
    "success": true
}

Send private reply

POST https://pages.fm/api/v1pages/[:page_id]/conversations/[:conversation_id]/messages?access_token=[:access_token]

Dùng để gửi tin nhắn từ bình luận Gửi tin nhắn từ bình luận chỉ gửi được một lần duy nhất cho một comment. Theo quy định của Facebook chỉ gửi được tin nhắn cho bình luận được tạo không quá 7 ngày.

Query Parameters

NameTypeDescription

access_token

string

Chuỗi token của khách hàng cung cấp từ Pancake

Headers

NameTypeDescription

page_id

string

ID trang của bạn

conversation_id

string

ID hội thoại chứa bình luận

Request Body

NameTypeDescription

post_id

string

ID bài viết chứa bình luận đó

message_id

string

ID bình luận mà bạn muốn gửi tin nhắn từ bình luận đó

action

string

Để gửi tin nhắn từ bình luận cần đặt giá trị private_replies

message

string

Nội dung trả lời

{
    "id": "m_5js02va40Z7Z5wUp2aPdbdmaxJ0QidmArUGPAjhej4U3LfA7WGMI62EL5qtJE_1FRXMtVlbDLd9dmmaIR5-ZAw",
    "success": true
}

Send inbox

POST https://pages.fm/api/v1/pages/[:page_id]/conversations/[:conversation_id]/messages?access_token=[:access_token]

Gửi tin nhắn tới khách hàng

Query Parameters

NameTypeDescription

access_token

string

Chuỗi token của khách hàng cung cấp từ Pancake

Headers

NameTypeDescription

page_id

string

ID trang của bạn

conversation_id

string

ID hội thoại

Request Body

NameTypeDescription

name

string

Tên của file

mime_type

string

mime_type của file muốn gửi(image,...)

content_url

string

Đường dẫn của hình ảnh(file) muốn gửi (https://i.ibb.co/mzh7ck8/alaska-beo-acef3fcb1cc541a79048f4bbafed71c8-grande.png)

attachmentType

string

Kiểu dữ liệu của attachment muốn gửi (PHOTO, DOCUMENT)

action

string

Để gửi tin nhắn cần đặt giá trị reply_inbox

message

string

Nội dung tin nhắn

thread_key

string

key của hội thoại muốn gửi tin nhắn

{
    "id":"m_kigIWuq85mIn7ijgUznKbdmaxJ0QidmArUGPAjhej4VUI3t48g39Ixhgpz3QTulmD42DFW386WgoS6DJ3EnbNw",
    "success":true
}

Get messages

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/conversations/[:conversation_id]/messages

Query Parameters

NameTypeDescription

current_count

number

Dùng để đánh index vị trí muốn lấy tin nhắn - Khi gọi API không truyền current_count hệ thống sẽ trả về 20 tin nhắn mới nhất. - Tiếp tục khi truyền tham số current_count là 20 hệ thống sẽ trả về 25 tin nhắn cũ hơn từ vị trí thứ 20 - Lưu ý: khi không truyền current_count sẽ trả về 20 tin nhắn, có current_count sẽ trả về 25 tin nhắn

access_token*

string

Chuỗi access_token của khách hàng cung cấp từ Pancake

customer_id*

string

ID của khách hàng(Lấy từ api get conversation)

conversation_id*

string

ID hội thoại của bạn muốn lấy tin nhắn(Lấy từ api get conversation)

page_id*

string

ID trang của bạn muốn lấy dữ

{
    messages: [...],
    ...
}

Engagement statistics

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/statistics/customer_engagements

Query Parameters

NameTypeDescription

by_hour

boolean

Thống kê theo giờ

date_range*

string

Khoảng thời gian thống kê (ví dụ: 27/07/2021 00:00:00 - 26/08/2021 23:59:59)

access_token*

string

Chuỗi token của page (Khách hàng có thể tạo ở mục cài đặt công cụ)

{
    "data": {
        "categories": ["26/8", "25/8", "24/8", "23/8", "22/8", "21/8", "20/8", "19/8", "18/8", "17/8", "16/8", "15/8", "14/8", "13/8", "12/8", "11/8", "10/8", "9/8", "8/8", "7/8", "6/8", "5/8", "4/8", "3/8", "2/8", "1/8", "31/7", "30/7", "29/7", "28/7", "27/7"],
        "series": [{
            "data": [0, 0, 2, 1, 0, 0, 1, 2, 2, 0, 3, 0, 3, 2, 0, 0, 6, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 6, 1, 3, 1],
            "name": "inbox"
        }, {
            "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "name": "comment"
        }, {
            "data": [0, 0, 2, 1, 0, 0, 1, 2, 2, 0, 3, 0, 3, 2, 0, 0, 6, 2, 0, 0, 0, 2, 1, 0, 0, 0, 0, 6, 1, 3, 1],
            "name": "total"
        }, {
            "data": [0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 1],
            "name": "new_customer_replied"
        }, {
            "data": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            "name": "customer_engagement_new_inbox"
        }]
    },
    "success": true
}

Chú thích:

    categories: danh sách ngày thống
    series: Dữ liệu thống kê
    series.data: Dữ liệu thống kê theo ngày tương ứng với danh sách categories
    series.name: Kiểu thống kê
        "inbox": Tương tác tin nhắn
        "comment": Tương tác comment
        "total": Tổng tương tác tin nhắn và 
        "new_customer_replied": Tương tác khách hàng 
        "customer_engagement_new_inbox": Hội thoại khách hàng 
        
        

by_hour:        
        
{
    "statistics": [{
        "comment": 0,
        "hour": "2021-08-26T13:00:00",
        "inbox": 1,
        "new_customer": 0,
        "new_customer_from_inbox": 0,
        "total": 1
    }, {
        "comment": 0,
        "hour": "2021-08-26T10:00:00",
        "inbox": 1,
        "new_customer": 0,
        "new_customer_from_inbox": 0,
        "total": 1
    }],
    "success": true
}

Users statatistics

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/statistics/users

Query Parameters

NameTypeDescription

access_token*

string

Chuỗi token của page (Khách hàng có thể tạo ở mục cài đặt công cụ)

date_range*

string

Khoảng thời gian thống kê (ví dụ: 27/07/2021 00:00:00 - 26/08/2021 23:59:59)

{
    "data": {
        "statistics": {
            "c5a50cce-fb0a-4eb3-892a-74ad182f7c03": [{
                "average_response_time": 3376234,
                "comment_count": 0,
                "hour": "2021-07-27T09:00:00",
                "inbox_count": 2,
                "phone_number_count": 0,
                "private_reply_count": 0,
                "unique_comment_count": 0,
                "unique_inbox_count": 1
            }, {
                "average_response_time": 74276,
                "comment_count": 0,
                "hour": "2021-07-28T10:00:00",
                "inbox_count": 6,
                "phone_number_count": 0,
                "private_reply_count": 0,
                "unique_comment_count": 0,
                "unique_inbox_count": 2
            }]
        },
        "users": {
            "c5a50cce-fb0a-4eb3-892a-74ad182f7c03": {
                "average_response_time": 588569,
                "comment_count": 0,
                "hour": "2021-08-26T13:00:00",
                "inbox_count": 637,
                "phone_number_count": 0,
                "private_reply_count": 0,
                "unique_comment_count": 0,
                "unique_inbox_count": 30,
                "user_fb_id": "570423649807405",
                "user_name": "Quyết Nguyễn"
            }
        }
    },
    "success": true
}

Chú thích:
    "statistics": Thống kê theo thời gian
    "users": Thống kê theo nhân viên
    "average_response_time": Thời gian phản hổi trung
    "comment_count": Tổng số bình luận thực 
    "inbox_count": Tổng số tin nhắn thực 
    "phone_number_count": Tổng số điện thoại
    "private_reply_count": "Hành động gửi tin nhắn từ bình luận",
    "unique_comment_count": Phản hồi cho mỗi bình luận của khách hàng (Thường bằng số bình luận của khách hàng)
    "unique_inbox_count": Phản hồi cho mỗi tin nhắn của khách hàng (Thường bằng số lượng tin nhắn của khách hàng)
    "hour": Thời gian thống kê
    "user_name": Tên nhân viên
    "user_fb_id": facebook id của nhân 

Conversations list detail

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/conversations

Query Parameters

NameTypeDescription

access_token*

string

Chuỗi token của page(Khách hàng có thể tạo ở mục cài đặt công cụ)

until*

number

Thời gian kết thúc(dạng unix)

since*

number

Thời gian bắt đầu(dạng unix)

page_id*

string

ID trang của khách hàng

page_number*

number

Trang hiện tại(nhỏ nhất 1)

{
  "conversations": [{
      "page_id": "wa_c.us@84328290781",
      "assignee_histories": [{
          "conversation_id": "wa_84328290781@c.us_62818166016@c.us",
          "inserted_at": "2021-08-26T06:29:56",
          "payload": {
              "added_users": [{
                  "email": "phamdongtx@gmail.com",
                  "fb_id": "1831989023699268",
                  "id": "82be33ea-729a-4e83-be15-2b7c83f34724",
                  "name": "Pham Dong"
              }],
              "deleted_users": []
          }
      }],
      "type": "INBOX",
      "inserted_at": "2021-08-26T06:29:56",
      "tags": [],
      "recent_phone_numbers": [],
      "customers": [{
          "avatar_url": "84328290781@c.us_1621224114",
          "fb_id": "wa_c.us@62818166016",
          "id": "d8526c77-832a-425c-8aee-e5d7dfcd7cd0",
          "name": "Babywearit (+62 81 816 6016)"
      }],
      "has_phone": false,
      "tag_histories": [],
      "post_id": null,
      "id": "wa_84328290781@c.us_62818166016@c.us",
      "last_sent_by": {
          "avatar_url": "84328290781@c.us_1621224114",
          "id": "wa_c.us@62818166016",
          "name": "Babywearit (+62 81 816 6016)",
          "phone_number": "62818166016"
      },
  }],
  "success": true,
  "total": 1
}

Chú thích
    "conversations": Danh sách hội thoại
        Chi tiết hội thoại:
            "page_id": id trang
            "assignee_histories": Lịch sử phân công hội thoại
            "type": Kiểu hội thoại(INBOX, COMMENT, RATING)
            "inserted_at": Thời  tạo hội thoại
            "tags": Tag hiện tại được gắn
            "recent_phone_numbers": Số điện thoại của hội thoại
            "customers": Thông tin khách hàng
            "has_phone": Có số điện thoại hay không
            "tag_histories": Lịch sử gắn gỡ tag
            "post_id": ID bài post nếu là comment
            "last_sent_by": Người gửi tin nhắn
            "current_assign_users": Danh sách phần công thời điểm hiện tại
            "ad_ids": Danh sách ad_id
    "total": Tổng số hội 

New customer statistics

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/statistics/customers

Thống kê khách hàng mới theo thời gian

Path Parameters

NameTypeDescription

group_by

string

Tuỳ chọn phương thức nhóm dữ liệu. Truyền vào một trong các string sau: - day (default): Trả về dữ liệu theo ngày - hour : Trả về dữ liệu theo giờ - page_id : Trả về dữ liệu theo các trang

access_token*

string

Chuỗi token của page(Khách hàng có thể tạo ở mục cài đặt công cụ)

date_range*

string

Khoảng thời gian cần thống kê ví dụ: 20/07/2020 - 20/08/2020

page_id*

string

ID trang của khách hàng

no group_by
{
    "data":[
        {"date":"2020-08-27","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-24","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12","new_customer_count":4,"new_page_inbox_count":3,"new_phone_number_count":0,"phone_number_count":0}
    ],
    "success":true
}

group_by: page_id
{
    "data": {
        "103205717747769": [
            {"date":"2020-08-12","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0}
        ],
        "110699180573884":[
            {"date":"2020-08-27","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0}
        ]
    },
    "success":true
}

group_by: hour
{
    "data":[
        {"date":"2020-08-12T16:00:00","new_customer_count":0,"new_page_inbox_count":1,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12T17:00:00","new_customer_count":0,"new_page_inbox_count":2,"new_phone_number_count":0,"phone_number_count":0},
        {"date":"2020-08-12T18:00:00","new_customer_count":4,"new_page_inbox_count":3,"new_phone_number_count":0,"phone_number_count":0}
    ],
    "success":true
}

Page customers

GET https://pages.fm/api/public_api/v1/pages/[:page_id]/page_customers

Query Parameters

NameTypeDescription

page_id*

String

ID trang của khách hàng

access_token*

String

Chuỗi token của page(Khách hàng có thể tạo ở mục cài đặt công cụ)

since*

number

Thời gian bắt đầu(dạng unix)

until*

number

Thời gian bắt đầu(dạng unix)

page_number*

number

Trang hiện tại(nhỏ nhất 1)

{
    "customers": [{
        "birthday": null,
        "gender": null,
        "inserted_at": "2021-06-07T11:11:16",
        "name": "Tạ Tuấn Vũ",
        "phone_numbers": [],
        "psid": "3296946846995244"
    }, {
        "birthday": null,
        "gender": "male",
        "inserted_at": "2021-06-07T11:11:09",
        "lives_in": "Hà Nội",
        "name": "Quyết Nguyễn",
        "phone_numbers": [],
        "psid": "2810250135746666"
    }, {
        "birthday": null,
        "gender": null,
        "inserted_at": "2021-03-27T16:55:33",
        "lives_in": "Hà Nội",
        "name": "Quyết Nguyễn",
        "phone_numbers": [],
        "psid": "1472648309584930"
    }],
    "success": true
}

Last updated