[ { "command": "order_status", "description": "retrieve an order status report", "triggers": [ { "pattern": "order status", "type": "string" }, { "type": "string", "pattern": "status" } ], "variables": [ { "name": "try_again", "type": "string" }, { "name": "satisfaction", "type": "string" }, { "name": "user_email", "type": "string" } ], "script": [ { "topic": "default", "script": [ { "text": [ "Thanks for shopping with us!" ] }, { "text": [ "What's the email address associated with your account?" ], "collect": { "key": "user_email", "options": [ { "default": true, "pattern": "default", "action": "invalid_email" }, { "pattern": "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])", "type": "regex", "action": "next" } ] } }, { "action": "status_report" } ] }, { "topic": "status_report", "script": [ { "text": [ "Here are the details from your last order:" ], "attachments": [ { "title": "Order #{{vars.order.id}}", "text": "{{vars.order.item}}", "fields": [ { "title": "", "value": "Ordered on {{vars.order.date}}" } ], "actions": [], "fallback": "", "color": "#666666", "image_url": "https://placeimg.com/640/480/tech" }, { "title": "Ship To:", "text": "{{vars.order.address.name}}", "fields": [ { "title": "", "value": "{{vars.order.address.line1}}" }, { "title": "", "value": "{{vars.order.address.line2}}" } ], "actions": [ { "text": "Change", "name": "change_address", "value": "{{vars.order.id}}", "type": "button" } ], "color": "#008000", "callback_id": "shippping_address" }, { "title": "Payment Method:", "text": "", "fields": [ { "title": "", "value": "**** **** **** {{vars.order.payment.last4}}" } ], "actions": [ { "text": "Change", "name": "change_payment", "value": "{{vars.order.id}}", "type": "button" } ], "callback_id": "billing", "color": "#00ff00", "thumb_url": "https://d3kgr2cjl1zxw7.cloudfront.net/mastercard_logo.png" }, { "title": "Shipping Info:", "text": "Arriving Saturday, April 8", "fields": [], "actions": [ { "text": "Track package", "name": "track", "value": "{{vars.order.id}}", "type": "button" }, { "text": "Cancel Items", "name": "cancel", "value": "{{vars.order.id}}", "type": "button", "style": "danger" } ], "callback_id": "shipping", "color": "#66ff66" } ] }, { "text": [ "Thank you!", "Thanks for being a customer!" ] }, { "action": "complete" } ] }, { "topic": "on_timeout", "script": [ { "text": [ "Looks like you got distracted. We can continue later." ] }, { "action": "timeout" } ] }, { "topic": "invalid_email", "script": [ { "text": [ "Sorry, that didn't seem like an email address. Please use the format `me@company.com`." ] }, { "action": "default" } ] }, { "topic": "does_not_exist", "script": [ { "text": [ "Sorry, no order can be found associated with that email address." ] }, { "text": [ "Do you want to try again?" ], "collect": { "key": "try_again", "options": [ { "default": true, "pattern": "default", "action": "next" }, { "pattern": "yes", "type": "utterance", "action": "default" } ] } }, { "text": [ "Ok! Any time you want to check another order, just say `order status`" ] }, { "action": "stop" } ] } ] } ]