SEND RECEIPT USING JSON API

Written by Saad Rawasia
Posted On Mar, 05, 2018
RECEIPT JSON RESPONSE FORMAT: {  "attachment": {  "type": "template",  "payload": {   "template_type": "receipt",   "recipient_name": "John Doe",   "order_number": "12345678902",   "currency": "USD",   "payment_method": "Visa 2345",   "order_url": "http://petersapparel.parseapp.com/order?order_id=123456",   "timestamp": "1428444852",   "address": {    "street_1": "1 Hacker Way",    "street_2": "",    "city": "Menlo Park",    "postal_code": "94025",    "state": "CA",    "country": "US"   },   "summary": {    "subtotal": 75.00,    "shipping_cost": 4.95,    "total_tax": 6.19,    "total_cost": 56.14  },  "adjustments": [{   "name": "New Customer Discount",   "amount": 20   },   {   "name": "$10 Off Coupon",   "amount": 10  }]  "elements": [{   "title": "Classic White T-Shirt",   "subtitle": "100% Soft and Luxurious Cotton",   "quantity": 2,   "price": 50,   "currency": "USD",   "image_url": "http://petersapparel.parseapp.com/img/whiteshirt.png"  },  {   "title": "Classic Gray T-Shirt",   "subtitle": "100% Soft and Luxurious Cotton",   "quantity": 1,   "price": 25,   "currency": "USD",   "image_url": "http://petersapparel.parseapp.com/img/grayshirt.png"  }  ]  }  } } HOW TO SEND RECEIPT TO YOUR CUSTOMER: For this tutorial we will create a form which will ask user its order number and send the receipt accordingly. Let’s start:
  • In the side menu go to Forms.
  • Click Create a Form Button.
  • Type in the name, you want to call your form and click Next.
  • Now, we will add fields to the form, in our case we only want order number, we will only add order number as field. But if you want other details, you can ask it. Then click Next.
  • Now enable the toggle for Call API with Response Data. Type in the API Url, select the method which you used to create your api, add any headers your api requires, and then scroll down, enable toggle for Allow multiple submission, because you want to allow your customers to ask for order as many times as they want. Then click Next.
  • Now Click the button with title “I will use with a Button”.
  • Now our form is created. Let’s create a story which will call this form. In the side menu go to New Story. For this story I will use keyword match, having value receipt order. Now add a Data collection plugin by clicking on plugin button, then click Data Collection or Form Button and select your receipt form you just created and then click add. Save story and you are done.
  • Now it’s time to test. Go to messenger and type receipt order.
Note*: Use the receipt format provided above.