Send Message By Payload Id
Version: 1.0
Context
This API will help you send messages to users via payload id (which you can get from setup Flow
in Harasocial).
Authenticated access scopes: social.conv
Requirements
- Must create & publish a
Flow
and get Flow'sPayload Id
and pass it to the api. - Must send message inside
24 hours message window
. (https://developers.facebook.com/docs/messenger-platform/policy/policy-overview/#contents)
Steps to get Flow's payload id:
- Go to https://app.harasocial.com/
- Access the menu
Chat Assistant
on the left side: https://app.harasocial.sku.vn/chat_assistant/ - On menu
Chat Assistant
, click sub menuContent
: https://app.harasocial.sku.vn/chat_assistant/{your_fb_page_id}/content/flow - Click
Create new Flow
on the top right area. - Enter
Flow name
in the popup and clickCreate
. - Setup your
Flow
. After done setup, clickPublish
. - Click
Share Payload
on the top right area. Then the popup will appear withPayload Id
(it looks like this:_hrf_f_...
). (See picture below). - Click
Copy
thePayload Id
thenSave
. - Use this
Payload Id
to send call API below. The PSID received a message by this api will go through theFlow
linked with thePayload Id
.
Request URI
- POST
https://apis.harasocial.com/social/messages.json
Example Request
curl -X 'POST' \
'https://apis.harasocial.com/social/messages.json' \
-H 'accept: text/plain' \
-H 'Authorization: Bearer {token}' \
-H 'Content-Type: application/json-patch+json' \
-d '{
"messaging_type": "harasocial_facebook_payload_id",
"recipient": {
"id": "2560816460648749"
},
"message": {
"payload_id": "__hrf_f_63072efd8d1cc15d16c3848e_s_4d12c525111725943cdbf556bd57687d"
},
"page_id": "500725830264749",
"metadata": "Custom string that is delivered as a message echo"
}'
Parameters
messaging_type
: string
"messaging_type": "harasocial_facebook_payload_id"
The messaging type of the message being sent. Payload Id message type is define by value harasocial_facebook_payload_id
recipient
: Recipient Object
"recipient": {
"id": "2560816460648749"
}
Recipient who received message. See Recipient Object
.
page_id
: string
"page_id": "500725830264749"
Page Id of the page will send this message
metadata
: string
"metadata": "Custom string that is delivered as a message echo"
Optional. Custom string that is delivered as a message echo. 500 character limit.
message
: Payload Id Object
"message": {
"payload_id": "__hrf_f_63072efd8d1cc15d16c3848e_s_4d12c525111725943cdbf556bd57687d"
}
Message Payload. See Payload Id Object
.
Recipient Object
id
: string
"id": "2560816460648749"
Page Scoped User ID (PSID) of the message recipient
Payload Id Object
payload_id
: string
"payload_id": "__hrf_f_63072efd8d1cc15d16c3848e_s_4d12c525111725943cdbf556bd57687d"
Id of a payload which get from setup content in Harasocial
Response
A successful Send Messages API request returns a JSON string containing status indicates that the request was passed validation and the system will process it.
Example
{
"data": {
"success": true
},
"has_error": false,
"error_code": null,
"error_message": null
}
Properties
data
: Success Object
"data": {
"success": true
}
The result of the action. See Success Object
below.
has_error
: bool
True if the request does not meet requirement or validation
error_code
: string
The error code information
error_message
: string
The error message information
Success Object
success
: bool
"success": true
Status indicates that the request was passed validation and the system will process it