Message Event
当会员发送消息或文件、点击按钮或与聊天机器人互动时,将向Stella发送一个消息事件。this.messageEvent是一个代表会员行动的对象。消息事件对象在不同的平台上略有不同。this.messageEvent.type和this.messageEvent.data对所有平台都是通用的,包含了大多数常见使用情况的信息。
我们可以使用这些信息来确定用户移动到哪个节点(见触发器/条件),并保存用户对聊天机器人问题的回答(见动作)。
例子:
this.messageEvent.data.text
// => "TEXT"
脸书
| Property | Type | Description |
|---|---|---|
| data | object | Message data |
| from | string | PSID of the user |
| messageId | string | Optional Message ID |
| origin | string | Optional Message origin. Values include: CUSTOMER_CHAT_PLUGIN, and MESSENGER |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | string | Page ID |
| type | string | Message type. Values include TEXT, PAYLOAD, REFERRAL, DELIVERY, ECHO, READ, OPTIN, ACCOUNT_LINKING, PASS_THREAD_CONTROL, REQUEST_THREAD_CONTROL, TAKE_THREAD_CONTROL, APP_ROLES, POLICY_ENFORCEMENT, and MISC. |
For further reference of type TEXT, PAYLOAD, REFERRAL, DELIVERY, ECHO, READ, OPTIN, ACCOUNT_LINKING, POLICY_ENFORCEMENT and MISC, please see the Facebook documentation.
For further reference of type PASS_THREAD_CONTROL, REQUEST_THREAD_CONTROL, TAKE_THREAD_CONTROL, APP_ROLES, please see the Facebook documentation.
data object
| Property | Type | Description |
|---|---|---|
| accountLinking | object | ACCOUNT_LINKING. Information about the link account or unlink account are clicked |
| app_id | string | ECHO TYPE ONLY. ID of the app from which the message was sent |
| appRoles | object | APP_ROLES TYPE ONLY. Contains Page ID |
| attachments | array<object> | Available only when there is an attachment |
| delivery | object | DELIVERY TYPE ONLY. Information about delivered message of a Facebook page |
| metadata | string | ECHO TYPE ONLY. Custom string |
| passThreadControl | object | PASS_THREAD_CONTROL TYPE ONLY. Information about passing the control of one conversation from one app to another |
| payload | string | PAYLOAD TYPE ONLY. Custom data provided by the app |
| policyEnforcement | object | POLICY_ENFORCEMENT TYPE ONLY. Information about policy enforcement |
| referral | object | PAYLOAD AND REFERRAL TYPE ONLY. Referral information. |
| requestThreadControl | object | REQUEST_THREAD_CONTROL TYPE ONLY. Information about requesting control of one conversation of one app |
| read | object | READ TYPE ONLY. Information about read message of a Facebook page |
| takeThreadControl | object | TAKE_THREAD_CONTROL ONLY. Information about taking control of one conversation from a secondary app |
| text | string | TEXT TYPE ONLY. Message text |
| title | string | Title of the call-to-action button |
attachment object
| Property | Type | Description |
|---|---|---|
| type | string | Attachment type. Values include IMAGE, VIDEO, AUDIO, LOCATION, FILE, FALLBACK, and TEMPLATE |
| url | string | Attachment URL. Available only on IMAGE, VIDEO, AUDIO, and FILE type. |
Slack
在Slack中,有3个不同的webhook事件,将组成不同的messageEvent对象。
斜线命令网络钩子
| Property | Type | Description |
|---|---|---|
| data | object | Message content |
| from | string | Sender ID |
| response_url | string | URL can be used to post responses to dialog submissions |
| teamId | string | Slack team ID |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | Slack channel ID | |
| type | string | Slack event type |
data object
| Property | Type | Description |
|---|---|---|
| payload | string | Slash event command |
| text | string | Message text content |
行动网络钩子
| Property | Type | Description |
|---|---|---|
| data | object | Message content |
| from | string | Sender ID |
| response_url | string | URL can be used to post responses to dialog submissions |
| teamId | string | Slack team ID |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | Slack channel ID | |
| type | string | Slack event type |
data object
| Property | Type | Description |
|---|---|---|
| callback_id | string | An identifier strictly for you to recognize submissions of this conversation |
| originalMessage | string | Message text content |
| payload | string | If there is a JSON value of in the first action, it is a Javascript object. Otherwise, it will return the original value. |
| trigger_id | string | Short-lived pointer, which expired in 3 seconds, to interaction's who, what, where, and when |
事件网络钩子
| Property | Type | Description |
|---|---|---|
| bot_id | string | Optional Slack bot ID |
| data | object | Message content |
| event | object | Message event in a more detailed manner |
| from | string | (bot_id AND isBot) Slack bot ID (default) sender ID |
| isBot | boolean | Optional Status of whether the conversation is conducted by bot |
| teamId | string | Slack team ID |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | string | Slack channel ID |
| type | string | Message type. Values include: TEXT, MISC, IMAGE |
data object
| Property | Type | Description |
|---|---|---|
| attachments | object | Attachment information inside data |
| text | string | Message text content |
attachments object
| Property | Type | Description |
|---|---|---|
| downloadUrl | string | Download URL of the file |
| type | string | Attachment type. Values include: IMAGE, VIDEO, FILE, and TEXT |
event object
| Property | Type | Description |
|---|---|---|
| subtype | string | Message subtype. Values include bot_message and file_share |
Teamwork
Coming soon...
| Property | Type | Description |
|---|---|---|
| data | object | Message data |
| from | string | WhatsApp ID of the sender of the original message |
| mentions | array<string> | List of mentioned IDs |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | string | WhatsApp ID of the receiver of the original message |
| type | string | Message type. Values include: TEXT, MISC, and SYSTEM |
data object
| Property | Type | Description |
|---|---|---|
| attachments | array<object> | Message attachments. This field will not be available when the type of the message is TEXT or SYSTEM |
| system | object | System message information. Please see the Facebook documentation for further reference |
| text | string | Message text content. This field is available only the message type is TEXT |
attachements object
| Property | Type | Description |
|---|---|---|
| caption | string | Caption of the attachment |
| opus | boolean | Audio format. Available only for the 1st item in the attachments array |
| type | string | Attachment type. Values include: IMAGE, VIDEO, AUDIO, and FILE |
| waMediaId | string | WhatsApp media ID |
Web Chat
| Property | Type | Description |
|---|---|---|
| data | object | Message data |
| from | string | User ID |
| messageId | string | Optional Message ID |
| timestamp | number | Time of update (epoch time in milliseconds) |
| to | string | Bot ID, in webchat, this is usually channel ID |
| type | string | Message type. Values include TEXT, PAYLOAD, MISC , WEB_ACTION. |
data object
| Property | Type | Description |
|---|---|---|
| text | string | Message text content |
| payload | string | PAYLOAD TYPE ONLY. Custom data provided by the app |
| attachments | array<object> | Available only when there is an attachment |
attachment object
| Property | Type | Description |
|---|---|---|
| type | string | Attachment type. Values include IMAGE, VIDEO, AUDIO, FILE |
| url | string | Attachment URL. Available only on IMAGE, VIDEO, AUDIO, and FILE type. |
Coming soon...
