Skip to content

Instantly share code, notes, and snippets.

@mepesh
Last active March 30, 2020 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mepesh/455d86efe28a9af632aa31fbbdcceecf to your computer and use it in GitHub Desktop.
Save mepesh/455d86efe28a9af632aa31fbbdcceecf to your computer and use it in GitHub Desktop.
dialogueflow-custom-payloads-card-templete
elif(intent == "news-nepal-int"):
url = "https://nepalcorona.info/api/v1/news"
response = requests.get(url)
news = json.loads(response.text)
data = news['data']
data1 = data[0]
data2 = data[1]
data3 = data[2]
# response1 = "Here are the latest news \n"+data1['url']+"\n"+data2['url']+"\n"+data3['url']
response2 = [{
"card":{
"title":data1['title'],
"subtitle":"Source: "+data1['source']+" >>",
"imageUri":data1['image_url'],
"buttons":[
{
"text":"Read Full Story",
"postback":data1['url']
},
{
"type":"postback",
"title":"Symptoms",
"payload":"symptoms"
}
]
},
"platform":"FACEBOOK"
},
{
"text":{"text":["Dummy text"]}
},
{
"card":{
"title":data2['title'],
"subtitle":"Source "+data2['source']+" >>",
"imageUri":data2['image_url'],
"buttons":[
{
"text":"Read Full Story",
"postback":data2['url']
},
{
"type":"postback",
"title":"Live Nepal Data",
"payload":"live-nepal-data"
}
]
},
"platform":"FACEBOOK"
},
{
"text":{"text":["Dummy text"]}
},
{
"card":{
"title":data3['title'],
"subtitle":"Source "+data3['source']+" >>",
"imageUri":data3['image_url'],
"buttons":[
{
"text":"Read Full Story",
"postback":data3['url']
},
{
"type":"postback",
"title":"Live Nepal Data",
"payload":"live-nepal-data"
}
]
},
"platform":"FACEBOOK"
},
{
"text":{"text":["Dummy text"]}
}
]
reply = { "fulfillmentMessages": response2 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment