Messages

Run in Postman

Message resource is the main entry point for sending messages. To send a message, you have to specify a Facebook contact with one of the following attributes:

Contact Id

You receive contact.id when the user starts a conversation with you, see Entry Points for more details.

{
  "contact": {  
    "id": "6456078781510718339"
  },
  "channel": {...},
  "content": {...}
}
{
  "id": "...",
  "contact": {
    "id": "6456078781510718339"
  },
  "channel": {...},
  "content": {...}
}

Phone Number

You can send a message using a phone number you already have (see Phone Number Entry Point for more details). Attributes first_name and last_name are optional and just help to match the phone number with an existing Facebook User.

{
  "contact": {
    "phone_number": "+1 (555) 857-6309",
    "first_name": "Anthony",
    "last_name": "Hopkins"
  },
  "channel": {...},
  "content": {...}
}
{
  "id": "...",
  "contact": {
    "id": "15234390803083474",
    "phone_number": "15558576309"
  },
  "channel": {...},
  "content": {...}
}

🚧

Opt-in and Messages Delivered Webhooks

When you send a message using phone number, you can listen to Opt-in Webhook which is fired when the user confirms your request. You should however also listen to Messages Delivered Webhook which is fired for any further message sent after the user opts in.

🚧

Phone Number Format

Note that the phone number in response is in E.164 format. All responses and webhooks coming from Amio use this format.

User Ref

Opt-in Webhook delivers a user_ref attribute which can be used for sending the first message to the user.

{
  "contact": {
    "user_ref": "{{YOUR_CUSTOM_USER_REF}}"
  },
  "channel": {...},
  "content": {...}
}
{
  "id": "...",
  "contact": {
    "id": "15234390803083474",
    "user_ref": "{{YOUR_CUSTOM_USER_REF}}"
  },
  "channel": {...},
  "content": {...}
}