TipoAgent · llm
Regras0
Canalany
Versão1.0.0
zapgpt-environment6.4 KB
ZapGPT
Agente de uso geral em português com DeepSeek Reasoner e 8 ferramentas de ações diretas: busca na web, busca de imagens + envio, links temporários de mídia com Mediagator, busca de notícias GDELT + extração de conteúdo, memória persistente de comportamentos por contato e limpeza de memória da conversa.
Baixar ZIP · 6.4 KB
Configuração obrigatória
Crie estas variáveis de configuração da empresa antes de importar ou executar as ferramentas. Os valores de URL base não devem terminar com barra.
| Variável | Valor |
|---|---|
ZapGPT_SEARCH_BASE_URL | URL base compatível com SearXNG, por exemplo https://<your-search-service> |
ZapGPT_GDELT_BASE_URL | URL base do proxy GDELT, por exemplo https://<your-gdelt-proxy> |
ZapGPT_MEDIAGATOR_BASE_URL | URL do endpoint do Mediagator, por exemplo https://<your-mediagator-service> |
ZapGPT_MEDIAGATOR_API_KEY | Chave de API do Mediagator |
JSON Completo
Clique para expandir
{
"description": "General-purpose Portuguese DeepSeek Reasoner agent with 8 direct tools: web search, image search + send, Mediagator temporary media links, GDELT news search + content extraction, persistent per-contact behavior memory, and conversation memory clearing.",
"tags": [
"agent",
"llm",
"deepseek",
"web-search",
"images",
"media-download",
"news",
"portuguese",
"tools",
"error-handling",
"searxng",
"gdelt",
"mediagator",
"direct-actions",
"config-variables"
],
"linkedExamples": [],
"document": {
"name": "ZapGPT",
"agentType": "llm",
"platformType": "deepseek",
"platform": {
"llm": {
"model": "deepseek-flash",
"apiMode": "chat_completions",
"temperature": 1,
"maxCharsPerMessage": 1024,
"enableByok": false,
"enableStructuredOutputs": false,
"enableContextTokenBudget": false,
"enableImageProcessing": false,
"imageProcessingQuality": "auto",
"preActions": [],
"systemRoleMessages": [
{
"expr": "\"Voce e o ZapGPT, agente virtual construido na plataforma AutoTalk (https://autotalk.io). Voce esta conversando com \" + contact.name + \". Agora sao \" + datetime.format(datetime.now(), \"DD/MM/YYYY HH:mm\", \"America/Sao_Paulo\") + \" em America/Sao_Paulo. Responda no idioma do usuario. Seja direto por padrao, mas seja transparente quando usar ferramentas: avise antes de trabalhos demorados e explique claramente o resultado ou a falha.\"",
"onFailure": "keep",
"fallback": "",
"resultType": "any",
"strict": false
},
{
"expr": "values.present((values.coalesce(maps.get(contact.customAttributes, \"zapgptBehaviors\", \"\"), \"\")).trim()) ? \"Comportamentos persistentes definidos por \" + contact.name + \" em contact.customAttributes.zapgptBehaviors: \" + (values.coalesce(maps.get(contact.customAttributes, \"zapgptBehaviors\", \"\"), \"\")).trim() + \". Siga essas preferencias nas respostas futuras, exceto se entrarem em conflito com instrucoes de prioridade maior.\" : \"\"",
"onFailure": "keep",
"fallback": "",
"resultType": "any",
"strict": false
},
{
"expr": "\"Quando a ferramenta busca_imagem retornar opcoes relevantes e o usuario quiser receber uma imagem, escolha uma URL retornada por ela e chame enviar_imagem_url. Para videos ou audio, use baixar_midia apenas quando o usuario pedir para baixar, converter ou extrair midia de uma URL. Nunca invente URLs de imagem, video, audio ou download.\"",
"onFailure": "keep",
"fallback": "",
"resultType": "any",
"strict": false
},
{
"expr": "\"Politica de ferramentas do ZapGPT: use faz_busca para fatos atuais, precos, links, informacoes recentes ou quando nao tiver certeza. Use buscar_noticias_gdelt para noticias e obter_conteudo_noticia_gdelt antes de resumir uma URL/artigo especifico. Depois que uma ferramenta retornar dados, responda com base nesses dados e evite novas chamadas na resposta final, exceto quando a tarefa exigir claramente outra ferramenta. Evite mensagens intermediarias repetidas: em uma mesma solicitacao, envie no maximo uma mensagem curta de progresso antes das ferramentas; se precisar chamar varias ferramentas, aguarde os resultados e responda uma unica vez com a sintese. Se uma ferramenta falhar, diga o que falhou, se vale tentar novamente, e use link temporario quando estiver disponivel. Nunca exponha chaves, tokens, payloads internos, IDs internos ou stack traces.\"",
"onFailure": "keep",
"fallback": "",
"resultType": "any",
"strict": false
}
],
"actions": [],
"toolChoiceType": "auto",
"tools": [
{
"type": "function",
"function": {
"name": "definir_comportamentos_zapgpt",
"description": "Salva comportamentos persistentes do ZapGPT para este contato em contact.customAttributes.zapgptBehaviors. Use quando o usuario pedir para o agente agir de um jeito especifico daqui para frente. Passe string vazia para limpar.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "behaviors",
"type": "string",
"description": "Instrucao persistente de comportamento para este contato. Passe string vazia para remover.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/data/company/resource/advanced/update_with_filter",
"actions/data/company/resource/advanced/update_with_filter": {
"dynadataItemType": "contacts",
"filter": {
"expr": "{\"_id\": contact._id}",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"payload": {
"expr": "{\"customAttributes.zapgptBehaviors\": values.present(behaviors) ? (behaviors).trim() : \"\"}",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"upsert": false
}
}
}
],
"output": {
"main": {
"expr": "values.present((behaviors).trim()) ? \"Comportamentos do ZapGPT salvos para este cliente\" : \"Comportamentos do ZapGPT removidos para este cliente\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "faz_busca",
"description": "Busca na internet com SearXNG e retorna resultados, sugestoes e infoboxes. Use para fatos atuais, links, precos, referencias e temas que podem ter mudado recentemente.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "query",
"type": "string",
"description": "Consulta da busca na internet.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
},
{
"name": "categories",
"type": "string",
"description": "Categorias opcionais do SearXNG, como general, news, images ou general,news.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "language",
"type": "string",
"description": "Codigo de idioma opcional, como pt-BR ou en-US.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "time_range",
"type": "string",
"description": "Filtro temporal opcional: day, month ou year.",
"enableEnums": true,
"defineAsCel": false,
"enumValues": [
"day",
"month",
"year"
],
"isRequired": false,
"objectProperties": []
},
{
"name": "pageno",
"type": "string",
"description": "Pagina opcional dos resultados.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Estou buscando na internet. Ja volto com as fontes principais.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/config/variables/resolve",
"actions/config/variables/resolve": {
"entries": [
{
"variableName": "ZapGPT_SEARCH_BASE_URL"
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url.params(ZapGPT_SEARCH_BASE_URL + \"/search\", {\"q\": query, \"format\": \"json\", \"categories\": categories, \"language\": language, \"time_range\": time_range, \"pageno\": pageno})",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [
{
"key": {
"expr": "\"Accept\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
}
],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "!workflow.stepOk(2)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "values.coalesce(maps.get(workflow.stepError(2), \"user_message\"), \"Nao consegui concluir a busca agora.\") + (values.coalesce(maps.get(workflow.stepError(2), \"retryable\", false)) ? \" Voce pode tentar novamente em instantes.\" : \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "toon.encode(workflow.stepOk(2) ? {\n \"ok\": true,\n \"query\": workflow.stepData(2, \"query\", query),\n \"number_of_results\": workflow.stepData(2, \"number_of_results\", 0),\n \"results\": workflow.stepData(2, \"results\", []),\n \"suggestions\": workflow.stepData(2, \"suggestions\", []),\n \"infoboxes\": workflow.stepData(2, \"infoboxes\", []),\n \"error\": null\n} : {\n \"ok\": false,\n \"query\": query,\n \"status\": maps.get(workflow.step(2), \"status\"),\n \"data\": workflow.stepData(2),\n \"error\": maps.defaults(workflow.stepError(2), {\n \"code\": maps.get(workflow.step(2), \"status\") != null ? \"http_request_failed\" : \"workflow_step_failed\",\n \"user_message\": values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao foi possivel concluir a busca na internet.\"),\n \"retryable\": false\n })\n})",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "busca_imagem",
"description": "Busca varias imagens na internet e retorna URLs e metadados. Se precisar enviar uma delas na conversa, use a ferramenta enviar_imagem_url com uma URL retornada por esta busca.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "query",
"type": "string",
"description": "Query da imagem a ser buscada",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
},
{
"name": "language",
"type": "string",
"description": "Codigo de idioma opcional, como pt-BR ou en-US.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "limit",
"type": "number",
"description": "Quantidade opcional de imagens para retornar. Padrao 10, com limite maximo de 25.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "pageno",
"type": "string",
"description": "Pagina opcional dos resultados.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Estou procurando imagens relevantes. Ja volto com as opcoes.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/config/variables/resolve",
"actions/config/variables/resolve": {
"entries": [
{
"variableName": "ZapGPT_SEARCH_BASE_URL"
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url.params(ZapGPT_SEARCH_BASE_URL + \"/search\", {\"q\": query, \"categories\": \"images\", \"format\": \"json\", \"language\": language, \"pageno\": pageno})",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [
{
"key": {
"expr": "\"Accept\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
}
],
"returnBuffer": false,
"cache": false
}
}
}
],
"output": {
"main": {
"expr": "toon.encode(workflow.stepOk(2) ? {\"ok\": true, \"query\": workflow.stepData(2, \"query\", query), \"search_status\": maps.get(workflow.step(2), \"status\"), \"limit_requested\": values.coalesce(limit, 10), \"limit_applied\": math.clamp(values.coalesce(limit, 10), 1, 25), \"total_results\": workflow.stepData(2, \"number_of_results\", size(workflow.stepData(2, \"results\", []))), \"number_of_results\": size(lists.slice(workflow.stepData(2, \"results\", []), 0, math.clamp(values.coalesce(limit, 10), 1, 25))), \"images\": lists.slice(workflow.stepData(2, \"results\", []), 0, math.clamp(values.coalesce(limit, 10), 1, 25)), \"suggestions\": workflow.stepData(2, \"suggestions\", []), \"error\": null} : {\"ok\": false, \"query\": query, \"status\": maps.get(workflow.step(2), \"status\"), \"data\": workflow.stepData(2), \"error\": maps.defaults(workflow.stepError(2), {\"code\": maps.get(workflow.step(2), \"status\") != null ? \"image_search_request_failed\" : \"workflow_step_failed\", \"user_message\": values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao foi possivel consultar imagens agora.\"), \"retryable\": false})})",
"onFailure": "throw",
"fallback": "{}",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "enviar_imagem_url",
"description": "Baixa e envia na conversa uma imagem a partir de uma URL direta. Use preferencialmente uma URL retornada pela ferramenta busca_imagem.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "url",
"type": "string",
"description": "URL direta da imagem a ser enviada.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
},
{
"name": "caption",
"type": "string",
"description": "Legenda opcional para acompanhar a imagem.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "file_name",
"type": "string",
"description": "Nome de arquivo opcional para salvar a imagem baixada.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Vou baixar e enviar a imagem escolhida.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/download-to-storage",
"actions/network/http/download-to-storage": {
"url": {
"expr": "url",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [],
"fileName": {
"expr": "values.present(file_name) ? (file_name).trim() : dyn(null)",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"category": "images",
"isPublic": false,
"purpose": "action_response_media"
}
}
},
{
"condition": {
"expr": "maps.get(workflow.step(1), \"file\") != null",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "image",
"payload": {
"use_file_expression": true,
"fileExpression": {
"expr": "maps.get(workflow.step(1), \"file\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"text": {
"expr": "values.present(caption) ? (caption).trim() : \"\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "maps.get(workflow.step(1), \"file\") == null || maps.get(workflow.step(2), \"executionContext.status\") == \"failed\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "maps.get(workflow.step(1), \"file\") != null && maps.get(workflow.step(2), \"executionContext.status\") == \"failed\" ? (\"Consegui baixar a imagem, mas nao consegui enviar diretamente aqui.\" + (values.present(maps.get(workflow.step(1), \"signedUrl\")) ? \" Link temporario: \" + maps.get(workflow.step(1), \"signedUrl\") : \" Tente novamente em instantes.\")) : (values.coalesce(maps.get(workflow.stepError(1), \"user_message\"), \"Nao consegui enviar a imagem dessa URL.\") + (values.coalesce(maps.get(workflow.stepError(1), \"retryable\", false)) ? \" Voce pode tentar novamente em instantes.\" : \"\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "maps.get(workflow.step(1), \"file\") != null && maps.get(workflow.step(2), \"executionContext.status\") != \"failed\" ? \"Imagem enviada\" : (maps.get(workflow.step(1), \"file\") != null ? \"Imagem baixada e salva, mas o envio direto falhou. Link temporario enviado quando disponivel.\" : values.coalesce(maps.get(workflow.step(2), \"executionContext.safeError.userMessage\"), maps.get(workflow.stepError(1), \"user_message\"), \"Nao consegui enviar a imagem dessa URL.\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "baixar_midia",
"description": "Baixa um video ou extrai audio de uma URL suportada pelo Mediagator, como YouTube, Instagram, TikTok, X/Twitter, Facebook, Vimeo, Reddit, SoundCloud e outros, e retorna um link temporario para download. Use quando o usuario pedir para baixar, converter ou extrair midia de uma URL.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "url",
"type": "string",
"description": "URL suportada pelo Mediagator para baixar video ou audio, como YouTube, Instagram, TikTok, X/Twitter, Facebook, Vimeo, Reddit, SoundCloud e outros.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
},
{
"name": "media_type",
"type": "string",
"description": "Tipo de midia: video ou audio. Padrao video.",
"enableEnums": true,
"defineAsCel": false,
"enumValues": [
"video",
"audio"
],
"isRequired": false,
"objectProperties": []
},
{
"name": "quality",
"type": "string",
"description": "Qualidade do video, como 720 ou 1080. Ignorada para audio.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "audio_format",
"type": "string",
"description": "Formato do audio quando media_type for audio. Padrao mp3.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "caption",
"type": "string",
"description": "Legenda opcional para acompanhar a midia enviada.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "(values.present(media_type) && (media_type).trim() == \"audio\") ? \"Vou extrair o audio agora. Isso pode levar alguns instantes; aviso quando terminar.\" : \"Vou baixar o video agora. Isso pode levar alguns instantes; aviso quando terminar.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/config/variables/resolve",
"actions/config/variables/resolve": {
"entries": [
{
"variableName": "ZapGPT_MEDIAGATOR_BASE_URL"
},
{
"variableName": "ZapGPT_MEDIAGATOR_API_KEY"
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "POST",
"url": {
"expr": "ZapGPT_MEDIAGATOR_BASE_URL",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [
{
"key": {
"expr": "\"Accept\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
},
{
"key": {
"expr": "\"Content-Type\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
},
{
"key": {
"expr": "\"Authorization\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"Api-Key \" + ZapGPT_MEDIAGATOR_API_KEY",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
}
],
"body": {
"expr": "(values.present(media_type) ? (media_type).trim() : \"video\") == \"audio\" ? json.stringify({\"url\": url, \"format\": \"audio\", \"audio_format\": values.present(audio_format) ? (audio_format).trim() : \"mp3\"}) : (values.present(quality) ? json.stringify({\"url\": url, \"quality\": (quality).trim()}) : json.stringify({\"url\": url}))",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "maps.get(workflow.step(2), \"status\") == 200 && values.present(workflow.stepData(2, \"download_url\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Mediagator gerou um link temporario para a midia.\" + (values.present(workflow.stepData(2, \"filename\")) ? \"\\nArquivo: \" + workflow.stepData(2, \"filename\") : \"\") + \"\\nLink temporario: \" + workflow.stepData(2, \"download_url\") + (values.present(caption) ? \"\\nLegenda: \" + (caption).trim() : \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "maps.get(workflow.step(2), \"executionContext.status\") == \"failed\" || maps.get(workflow.step(2), \"status\", 0) != 200 || !values.present(workflow.stepData(2, \"download_url\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "maps.get(workflow.step(2), \"executionContext.status\") == \"failed\" ? values.coalesce(maps.get(workflow.stepError(2), \"user_message\"), \"Nao consegui baixar a midia agora.\") : (maps.get(workflow.step(2), \"status\", 0) != 200 ? values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao consegui baixar a midia agora.\") : \"A origem nao disponibilizou um link de download para essa midia.\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "maps.get(workflow.step(2), \"status\") == 200 && values.present(workflow.stepData(2, \"download_url\")) ? (\"Link temporario gerado: \" + workflow.stepData(2, \"download_url\") + (values.present(workflow.stepData(2, \"filename\")) ? \" (\" + workflow.stepData(2, \"filename\") + \")\" : \"\")) : (maps.get(workflow.step(2), \"executionContext.status\") == \"failed\" ? values.coalesce(maps.get(workflow.stepError(2), \"user_message\"), \"Nao consegui baixar a midia agora.\") : (maps.get(workflow.step(2), \"status\", 0) != 200 ? values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao consegui baixar a midia agora.\") : \"A origem nao disponibilizou um link de download para essa midia.\"))",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "buscar_noticias_gdelt",
"description": "Busca noticias no GDELT e retorna artigos ou timeline conforme o modo informado.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "query",
"type": "string",
"description": "Consulta principal para buscar noticias.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
},
{
"name": "mode",
"type": "string",
"description": "Modo do GDELT DOC: ArtList, TimelineVol ou TimelineTone.",
"enableEnums": true,
"defineAsCel": false,
"enumValues": [
"ArtList",
"TimelineVol",
"TimelineTone"
],
"isRequired": false,
"objectProperties": []
},
{
"name": "timespan",
"type": "string",
"description": "Janela relativa como 15min, 3h, 7d, 2w ou 1m.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "startdatetime",
"type": "string",
"description": "Data inicial absoluta no formato YYYYMMDDHHMMSS.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "enddatetime",
"type": "string",
"description": "Data final absoluta no formato YYYYMMDDHHMMSS.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "maxrecords",
"type": "string",
"description": "Quantidade maxima de resultados a solicitar.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "sort",
"type": "string",
"description": "Ordenacao dos resultados.",
"enableEnums": true,
"defineAsCel": false,
"enumValues": [
"datedesc",
"dateasc",
"tonedesc",
"toneasc"
],
"isRequired": false,
"objectProperties": []
},
{
"name": "domain",
"type": "string",
"description": "Dominio da fonte, como reuters.com.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "theme",
"type": "string",
"description": "Tema GDELT para filtrar resultados.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "sourcelang",
"type": "string",
"description": "Idioma da fonte para compatibilidade com o endpoint DOC.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
},
{
"name": "sourcecountry",
"type": "string",
"description": "Pais da fonte para compatibilidade com o endpoint DOC.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": false,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Estou buscando noticias recentes. Ja volto com os resultados.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/config/variables/resolve",
"actions/config/variables/resolve": {
"entries": [
{
"variableName": "ZapGPT_GDELT_BASE_URL"
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url.params(ZapGPT_GDELT_BASE_URL + \"/doc\", {\"query\": query, \"format\": \"json\", \"mode\": values.present(mode) ? (mode).trim() : \"ArtList\", \"timespan\": timespan, \"startdatetime\": startdatetime, \"enddatetime\": enddatetime, \"maxrecords\": maxrecords, \"sort\": sort, \"domain\": domain, \"theme\": theme, \"sourcelang\": sourcelang, \"sourcecountry\": sourcecountry})",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [
{
"key": {
"expr": "\"Accept\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
}
],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "!workflow.stepOk(2)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "values.coalesce(maps.get(workflow.stepError(2), \"user_message\"), \"Nao consegui buscar noticias agora.\") + (values.coalesce(maps.get(workflow.stepError(2), \"retryable\", false)) ? \" Voce pode tentar novamente em instantes.\" : \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "toon.encode(workflow.stepOk(2) ? {\n \"ok\": true,\n \"query\": query,\n \"mode\": values.present(mode) ? (mode).trim() : \"ArtList\",\n \"request\": {\n \"timespan\": timespan,\n \"startdatetime\": startdatetime,\n \"enddatetime\": enddatetime,\n \"maxrecords\": maxrecords,\n \"sort\": sort,\n \"domain\": domain,\n \"theme\": theme,\n \"sourcelang\": sourcelang,\n \"sourcecountry\": sourcecountry\n },\n \"article_count\": size(workflow.stepData(2, \"articles\", [])),\n \"articles\": workflow.stepData(2, \"articles\", []),\n \"timeline\": workflow.stepData(2, \"timeline\", []),\n \"data\": workflow.stepData(2),\n \"error\": null\n} : {\n \"ok\": false,\n \"query\": query,\n \"mode\": values.present(mode) ? (mode).trim() : \"ArtList\",\n \"status\": maps.get(workflow.step(2), \"status\"),\n \"data\": workflow.stepData(2),\n \"error\": maps.defaults(workflow.stepError(2), {\n \"code\": maps.get(workflow.step(2), \"status\") != null ? \"http_request_failed\" : \"workflow_step_failed\",\n \"user_message\": values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao foi possivel buscar noticias agora.\"),\n \"retryable\": false\n })\n})",
"onFailure": "throw",
"fallback": "{}",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "obter_conteudo_noticia_gdelt",
"description": "Baixa e extrai o conteudo completo de uma noticia a partir da URL usando o GDELT.",
"hidden": false,
"isZodTool": false,
"parameters": [
{
"name": "url",
"type": "string",
"description": "URL da noticia a ser extraida.",
"enableEnums": false,
"defineAsCel": false,
"enumValues": [],
"isRequired": true,
"objectProperties": []
}
],
"actions": [
{
"condition": {
"expr": "false",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Estou abrindo a noticia e extraindo o conteudo completo.\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/config/variables/resolve",
"actions/config/variables/resolve": {
"entries": [
{
"variableName": "ZapGPT_GDELT_BASE_URL"
}
]
}
}
},
{
"condition": {
"expr": "true",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/network/http/request/send",
"actions/network/http/request/send": {
"method": "GET",
"url": {
"expr": "url.params(ZapGPT_GDELT_BASE_URL + \"/doc/content\", {\"url\": url})",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"headers": [
{
"key": {
"expr": "\"Accept\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
},
"value": {
"expr": "\"application/json\"",
"onFailure": "fallback",
"fallback": "",
"resultType": "any",
"strict": false
}
}
],
"returnBuffer": false,
"cache": false
}
}
},
{
"condition": {
"expr": "!workflow.stepOk(2)",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "values.coalesce(maps.get(workflow.stepError(2), \"user_message\"), \"Nao consegui extrair o conteudo da noticia.\") + (values.coalesce(maps.get(workflow.stepError(2), \"retryable\", false)) ? \" Voce pode tentar novamente em instantes.\" : \"\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "toon.encode(workflow.stepOk(2) ? {\n \"ok\": true,\n \"url\": url,\n \"title\": workflow.stepData(2, \"title\"),\n \"content\": values.coalesce(workflow.stepData(2, \"content\"), workflow.stepData(2, \"text\"), workflow.stepData(2, \"full_text\")),\n \"data\": workflow.stepData(2),\n \"error\": null\n} : {\n \"ok\": false,\n \"url\": url,\n \"status\": maps.get(workflow.step(2), \"status\"),\n \"data\": workflow.stepData(2),\n \"error\": maps.defaults(workflow.stepError(2), {\n \"code\": maps.get(workflow.step(2), \"status\") != null ? \"http_request_failed\" : \"workflow_step_failed\",\n \"user_message\": values.coalesce(workflow.stepData(2, \"error\"), workflow.stepData(2, \"message\"), \"Nao foi possivel extrair o conteudo da noticia.\"),\n \"retryable\": false\n })\n})",
"onFailure": "throw",
"fallback": "{}",
"resultType": "any",
"strict": false
}
}
}
},
{
"type": "function",
"function": {
"name": "limpar_memoria",
"description": "Limpa o histórico da conversa",
"hidden": false,
"isZodTool": false,
"parameters": [],
"actions": [
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/ai/openai/memory/conversation/clear"
}
},
{
"condition": {
"expr": "true",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
},
"action": {
"actionType": "actions/messaging/conversation/response/compose",
"actions/messaging/conversation/response/compose": {
"messages": [
{
"type": "text",
"payload": {
"text": {
"expr": "\"Minha memória foi limpa\"",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
]
}
}
}
],
"output": {
"main": {
"expr": "maps.get(workflow.step(0), \"executionContext.status\") != \"failed\" ? \"Minha memória foi limpa\" : values.coalesce(maps.get(workflow.step(0), \"executionContext.safeError.userMessage\"), \"Não consegui limpar minha memória.\")",
"onFailure": "throw",
"fallback": "",
"resultType": "any",
"strict": false
}
}
}
}
],
"mcpServers": [],
"maxIterations": 1
}
},
"options": {
"log_level": "info",
"listenMessagesContaining": []
}
}
}