Opciones de Noticias Climáticas Para el Contacto
Workflow manual que obtiene cinco artículos de noticias relacionadas con el clima en GDELT, los envía como opciones interactivas al contacto y devuelve el texto completo del artículo después de que el contacto seleccione uno.
Descargar ZIP · 2.1 KB
Antes de Importar
Las URLs de este ejemplo usan un marcador de posición https://<your-gdelt-proxy> que debe reemplazar por un servicio que usted mismo aloje:
- Paso 1 llama a
<your-gdelt-proxy>/doccon parámetros de consulta de GDELT DOC 2.0 (query,mode=ArtList,maxrecords,format=json) y espera una respuesta JSON con un arregloarticlesen el que cada artículo tiene untitley unaurl. Esto coincide con lo que devuelve el endpoint público de GDELThttps://api.gdeltproject.org/api/v2/doc/doc, por lo que su proxy puede reenviar esta llamada tal cual. - Las acciones de opción llaman a
<your-gdelt-proxy>/doc/contentcon un parámetrourly esperan una respuesta JSON con un campotextque contiene el cuerpo extraído del artículo (un campotitleopcional se usa como encabezado cuando está presente). La API pública de GDELT no tiene un endpoint de extracción de texto de artículos, por lo que su servicio debe implementar esta parte por sí mismo (por ejemplo, obteniendo la URL del artículo y extrayendo su texto legible).
Si solo necesita el listado de artículos sin el texto completo, consulte Obtener Noticias Públicas GDELT (String Codificada), que llama directamente a la API pública de GDELT.
JSON Completo
Clic para expandir
{
"description": "Manual workflow that fetches five climate-related GDELT news articles, sends them as interactive contact options, and returns the full article text after the contact selects one.",
"tags": [
"manual",
"messaging",
"options",
"news",
"gdelt",
"contact",
"interactive"
],
"document": {
"name": "Climate News Options To Contact",
"enabled": true,
"log_level": "info",
"trigger": {
"type": "manual"
},
"workflowInput": [
{
"name": "contact",
"description": "Contact to receive the news options",
"schema": {
"type": "ref",
"required": true,
"enableEnums": false,
"enum": [],
"ref": "contacts"
}
}
],
"steps": [
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "\"https://<your-gdelt-proxy>/doc?query=climate&mode=ArtList&maxrecords=5&format=json\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "present(contact) && step_ok(0) && size(step_data(0, \"articles\", [])) >= 5",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/contact/send",
"actions/messaging/contact/send": {
"use_manual_id": true,
"contactId_manual": {
"expr": "contact",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"messages": [
{
"type": "options",
"payload": {
"title": {
"expr": "\"Top 5 Climate News\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"description": {
"expr": "\"Choose one option to receive the complete story text.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"options": [
{
"label": {
"expr": "substring(coalesce(step(0).data.articles[0].title, \"News 1\"), 0, 24)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"value": {
"expr": "coalesce(step(0).data.articles[0].url, \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"actions": [
{
"condition": {
"expr": "present(coalesce(trigger.value, contactMessage.body.value))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url_params(\"https://<your-gdelt-proxy>/doc/content\", {\"url\": coalesce(trigger.value, contactMessage.body.value)})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "step_ok(0) && present(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(present(step_data(0, \"title\")) ? step_data(0, \"title\") + \"\\n\\n\" : \"\") + step_data(0, \"text\", \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "!step_ok(0) || blank(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't fetch the full story right now. Try another option in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"forwardMessageToAgent": false
},
{
"label": {
"expr": "substring(coalesce(step(0).data.articles[1].title, \"News 2\"), 0, 24)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"value": {
"expr": "coalesce(step(0).data.articles[1].url, \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"actions": [
{
"condition": {
"expr": "present(coalesce(trigger.value, contactMessage.body.value))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url_params(\"https://<your-gdelt-proxy>/doc/content\", {\"url\": coalesce(trigger.value, contactMessage.body.value)})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "step_ok(0) && present(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(present(step_data(0, \"title\")) ? step_data(0, \"title\") + \"\\n\\n\" : \"\") + step_data(0, \"text\", \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "!step_ok(0) || blank(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't fetch the full story right now. Try another option in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"forwardMessageToAgent": false
},
{
"label": {
"expr": "substring(coalesce(step(0).data.articles[2].title, \"News 3\"), 0, 24)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"value": {
"expr": "coalesce(step(0).data.articles[2].url, \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"actions": [
{
"condition": {
"expr": "present(coalesce(trigger.value, contactMessage.body.value))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url_params(\"https://<your-gdelt-proxy>/doc/content\", {\"url\": coalesce(trigger.value, contactMessage.body.value)})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "step_ok(0) && present(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(present(step_data(0, \"title\")) ? step_data(0, \"title\") + \"\\n\\n\" : \"\") + step_data(0, \"text\", \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "!step_ok(0) || blank(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't fetch the full story right now. Try another option in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"forwardMessageToAgent": false
},
{
"label": {
"expr": "substring(coalesce(step(0).data.articles[3].title, \"News 4\"), 0, 24)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"value": {
"expr": "coalesce(step(0).data.articles[3].url, \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"actions": [
{
"condition": {
"expr": "present(coalesce(trigger.value, contactMessage.body.value))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url_params(\"https://<your-gdelt-proxy>/doc/content\", {\"url\": coalesce(trigger.value, contactMessage.body.value)})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "step_ok(0) && present(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(present(step_data(0, \"title\")) ? step_data(0, \"title\") + \"\\n\\n\" : \"\") + step_data(0, \"text\", \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "!step_ok(0) || blank(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't fetch the full story right now. Try another option in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"forwardMessageToAgent": false
},
{
"label": {
"expr": "substring(coalesce(step(0).data.articles[4].title, \"News 5\"), 0, 24)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"value": {
"expr": "coalesce(step(0).data.articles[4].url, \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"actions": [
{
"condition": {
"expr": "present(coalesce(trigger.value, contactMessage.body.value))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url_params(\"https://<your-gdelt-proxy>/doc/content\", {\"url\": coalesce(trigger.value, contactMessage.body.value)})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"headers": [],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "step_ok(0) && present(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(present(step_data(0, \"title\")) ? step_data(0, \"title\") + \"\\n\\n\" : \"\") + step_data(0, \"text\", \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "!step_ok(0) || blank(step_data(0, \"text\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't fetch the full story right now. Try another option in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"forwardMessageToAgent": false
}
]
}
}
]
}
}
},
{
"condition": {
"expr": "present(contact) && !(step_ok(0) && size(step_data(0, \"articles\", [])) >= 5)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"action": {
"actionType": "actions/messaging/contact/send",
"actions/messaging/contact/send": {
"use_manual_id": true,
"contactId_manual": {
"expr": "contact",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"I couldn't load 5 climate news items right now. Please run this workflow again in a moment.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
}
}
}
]
}
}
}
],
"returnExpression": {
"expr": "{\"requestedContact\": contact, \"status\": step(0).status, \"articles\": get(step(0), \"data.articles\", [])}",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false,
"useSimpleCel": false
},
"customAttributes": {}
}
}