Skip to content

Instantly share code, notes, and snippets.

@CodingFu
Last active May 2, 2018 19:27
Show Gist options
  • Save CodingFu/65e83216073fbc970b32817c764527f6 to your computer and use it in GitHub Desktop.
Save CodingFu/65e83216073fbc970b32817c764527f6 to your computer and use it in GitHub Desktop.

About webhooks

all webhooks have type and timestamp in them

Subscribe webhook

{
  "type": "subscribe",
  "timestamp": "2017-04-24T12:43:59-04:00",
  
  "account_id": 123,
  "campaign_id": 123,
  "opt_id": 123,
  "phone_number": "4173962846",
  carrier_id: 77,
  carrier_name: Verizon,
  tag_list: ["tag_a", "tag_b"],

  // Custom fields (if any configured)
  "first_name": "John",
  "email": "test@foo.bar",
  "gender": null,
  "zip": null,
  "birthdate": null,
  
  "first_opt_in_timestamp": "2017-04-24T12:43:59-04:00",
  "last_opt_in_method": "keyword", // or API
  "last_opt_in_keyword": "HELLO",
}

Unsubscribe webhook

// pretty much as subscribe
{
  "type": "unsubscribe",
  "timestamp": "2017-04-24T12:43:59-04:00",
  
  "account_id": 123,
  "campaign_id": 123,
  "opt_id": 123,
  "phone_number": "4173962846",
  "carrier_id": 77,
  "carrier_name": Verizon,
  "tag_list": ["tag_a", "tag_b"],

  // Custom fields (if any configured)
  "first_name": "John",
  "email": "test@foo.bar",
  "gender": null,
  "zip": null,
  "birthdate": null,
  
  "first_opt_in_timestamp": "2017-04-24T12:43:59-04:00",
  "last_opt_in_method": "keyword", // or API
  "last_opt_in_keyword": "HELLO",

  // Note, this field is added to unsubscribe webhook
  "total_messages_received": 63,
}

Message Sent webhook

{
  "type": "message_sent",
  "timestamp": "2017-04-24T12:43:59-04:00",

  "account_id": 123,
  "campaign_id": 123,
  "message_id": 123,
  "sent_timestamp": "2017-04-24T12:43:59-04:00",

  "content": "Christmas sale, hurry up boys and girls!"

  "recipient_count": 2000,
  "success_count": 1900,
  "bounce_count": 50,
  "clean_count": 50,
  "unsubscribe_count": 0
}

Reply Received webhook

{
  "type": "campaign_response",
  "timestamp": "2017-04-24T12:43:59-04:00",

  "account_id": 123,
  "campaign_id": 123,
  "message_id": 123,
  "sent_timestamp": "2017-04-24T12:43:59-04:00",
  
  "content": "Christmas sale, hurry up boys and girls!",

  "response_timestamp": "2017-04-24T12:43:59-04:00",
  "reply_content": "I'll be in your shop in 5 minutes",
  "is_mms": true,
  "attachment_urls": ["http://tatango-mms-attachments-production.s3.amazonaws.com/attachments/images/000/001/432/medium/x.png"]

  "opt_id": 123,
  "phone_number": "4173962846",
  "carrier_id": 77,
  "carrier_name": Verizon,
  "tag_list": ["tag_a", "tag_b"],

  // Custom fields (if any configured)
  "first_name": "John",
  "email": "test@foo.bar",
  "gender": null,
  "zip": null,
  "birthdate": null,

  "first_opt_in_timestamp": "2017-04-24T12:43:59-04:00",
  "last_opt_in_method": "keyword", // or API
  "last_opt_in_keyword": "HELLO",
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment