การทำ custom payload line บน Dialogflow
////////////////////////////////////////// for flex message //////////////////////////
{
"line": {
"type": "flex",
"altText": "ข้อความที่แสดง",
"contents":
/// json from flex message simulator
}
}
//////////////////////////////////////////// carousel //////////////////
{
"line":
//// json from line bot designer
}
///////////////////////////////////////////// flex message ////////////////////////
{
"line": {
"type": "flex",
"altText": "ข้อความที่แสดง",
"contents":
{
"type": "bubble",
"styles": {
"footer": {
"backgroundColor": "#42b3f4"
}
},
"header": {
"type": "box",
"layout": "horizontal",
"contents": [
{
"type": "box",
"layout": "baseline",
"contents": [
{
"type": "icon",
"size": "xxl",
"url": "https://modcumram.com/logo_sapa.png"
}
]
},
{
"type": "box",
"layout": "vertical",
"flex": 5,
"contents": [
{
"type": "text",
"text": "รายงานสภาพอากาศ",
"weight": "bold",
"color": "#aaaaaa",
"size": "md",
"gravity": "top"
},
{
"type": "text",
"text": "ข้อมูลกรมอุตุนิยมวิทยา",
"weight": "bold",
"color": "#aaaaaa",
"size": "lg",
"gravity": "top"
}
]
}
]
},
"hero": {
"type": "image",
"url": "https://img.tsood.com/userfiles/image/3-1(10).jpg",
"size": "full",
"aspectRatio": "1:1",
"aspectMode": "cover",
"action": {
"type": "uri",
"uri": "https://www.tmd.go.th/programs/uploads/satda/latest.jpg"
}
},
"body": {
"type": "box",
"layout": "vertical",
"contents": [
{
"type": "text",
"margin": "sm",
"text": "สภาพอากาศและการจราจร",
"weight": "bold",
"size": "md",
"wrap": true
},
{
"type": "box",
"layout": "vertical",
"margin": "xs",
"contents": [
{
"type": "box",
"layout": "baseline",
"spacing": "sm",
"contents": [
{
"type": "text",
"text": "ที่มาข้อมูล กรมอุตินิยมวิทยาและ จส.100",
"wrap": true,
"color": "#666666",
"size": "sm",
"flex": 6
}
]
}
]
}
]
},
"footer": {
"type": "box",
"layout": "vertical",
"spacing": "sm",
"contents": [
{
"type": "button",
"style": "link",
"color": "#FFFFFF",
"height": "sm",
"action": {
"type": "message",
"label": "พยากรณ์อากาศประจำวัน",
"text": "อากาศกรุงเทพ"
}
},
{
"type": "button",
"style": "link",
"color": "#FFFFFF",
"height": "sm",
"action": {
"type": "uri",
"label": "ภาพถ่ายเรดาร์ฝน",
"uri": "https://www.tmd.go.th/programs/uploads/satda/latest.jpg"
}
},
{
"type": "button",
"style": "link",
"color": "#FFFFFF",
"height": "sm",
"action": {
"type": "uri",
"label": "เรดาห์ตรวจอากาศ",
"uri": "http://rain.tvis.in.th/rain_predict_android.php?lat=13.753364&lon=100.4954246"
}
},
{
"type": "button",
"style": "link",
"color": "#FFFFFF",
"height": "sm",
"action": {
"type": "message",
"label": "การจราจรและอุบัติเหตุ",
"text": "อุบัติเหตุ"
}
}
]
}
}
}
}
////////////////////////////////////// carousel ///////////
{
"line": {
"type": "template",
"altText": "บทความ",
"template": {
"type": "carousel",
"actions": [],
"columns": [
{
"thumbnailImageUrl": "https://sirichaiwatt.com/wp-content/uploads/2018/03/SirichaiwattAtt-01-326x236.jpg",
"title": "บทความดีดี สร้างแรงบันดาลใจ",
"text": "การพัฒนาตนเองแบบขี้เกียจ ๆ",
"actions": [
{
"type": "uri",
"label": "ดูรายละเอียด",
"uri": "https://sirichaiwatt.com/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%94%E0%B8%B5%E0%B9%86/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%9E%E0%B8%B1%E0%B8%92%E0%B8%99%E0%B8%B2%E0%B8%95%E0%B8%99%E0%B9%80%E0%B8%AD%E0%B8%87/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%9E%E0%B8%B1%E0%B8%92%E0%B8%99%E0%B8%B2%E0%B8%95%E0%B8%99%E0%B9%80%E0%B8%AD%E0%B8%87%E0%B9%81%E0%B8%9A%E0%B8%9A%E0%B8%82%E0%B8%B5%E0%B9%89%E0%B9%80%E0%B8%81%E0%B8%B5%E0%B8%A2%E0%B8%88%E0%B9%86"
}
]
},
{
"thumbnailImageUrl": "https://sirichaiwatt.com/wp-content/uploads/2017/07/Sirichaiwatt-Alife-01.jpg",
"title": "บทความดีดี สร้างแรงบันดาลใจ",
"text": "ปรับปรุง = พัฒนา ใช่ไหม ?",
"actions": [
{
"type": "uri",
"label": "ดูรายละเอียด",
"uri": "https://sirichaiwatt.com/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%94%E0%B8%B5%E0%B9%86/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%99%E0%B9%88%E0%B8%B2%E0%B8%AD%E0%B9%88%E0%B8%B2%E0%B8%99/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B9%81%E0%B8%87%E0%B9%88%E0%B8%84%E0%B8%B4%E0%B8%94/%E0%B8%9B%E0%B8%A3%E0%B8%B1%E0%B8%9A%E0%B8%9B%E0%B8%A3%E0%B8%B8%E0%B8%87-%E0%B8%9E%E0%B8%B1%E0%B8%92%E0%B8%99%E0%B8%B2"
}
]
},
{
"thumbnailImageUrl": "https://sirichaiwatt.com/wp-content/uploads/2016/09/Sirichaiwatt-OSTC-01-326x236.jpg",
"title": "บทความดีดี สร้างแรงบันดาลใจ",
"text": "หลอกตัวเองว่ามีความสุข แล้วสุขจริงหรือ?",
"actions": [
{
"type": "uri",
"label": "ดูรายละเอียด",
"uri": "https://sirichaiwatt.com/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%94%E0%B8%B5%E0%B9%86/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%99%E0%B9%88%E0%B8%B2%E0%B8%AD%E0%B9%88%E0%B8%B2%E0%B8%99/%E0%B8%9A%E0%B8%97%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%98%E0%B8%A3%E0%B8%A3%E0%B8%A1%E0%B8%B0/%E0%B8%AB%E0%B8%A5%E0%B8%AD%E0%B8%81%E0%B8%95%E0%B8%B1%E0%B8%A7%E0%B9%80%E0%B8%AD%E0%B8%87%E0%B8%A7%E0%B9%88%E0%B8%B2%E0%B8%A1%E0%B8%B5%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%AA%E0%B8%B8%E0%B8%82"
}
]
}
]
}
}
}
ความคิดเห็น
แสดงความคิดเห็น