Skip to main content

Exportar Conversa do Usuário

Este endpoint permite gerar uma visualização limpa e imprimível de uma conversa do usuário em formato HTML ou JSON.

Casos de uso

  • Gerar relatórios de conversas
  • Criar backups de conversas
  • Compartilhar conversas com outros usuários
  • Análise de histórico de atendimento

Parâmetros

ParâmetroTipoDescrição
idstringID da conversa (obrigatório)
formatstringFormato de exportação (html ou json)

Exemplos de código

const exportUserConversation = async (conversationId, format = 'html') => {
  const response = await fetch(`https://dash.superagentes.ai/api/user-conversations/export/${conversationId}?format=${format}`, {
    method: 'GET',
    headers: {
      'Authorization': `Bearer ${seu_token_jwt}`,
      'Content-Type': 'application/json'
    }
  });
  
  if (format === 'html') {
    const html = await response.text();
    return html;
  } else {
    const data = await response.json();
    return data;
  }
};
import requests

def export_user_conversation(conversation_id, format='html'):
    headers = {
        'Authorization': f'Bearer {seu_token_jwt}',
        'Content-Type': 'application/json'
    }
    
    params = {
        'format': format
    }
    
    response = requests.get(
        f'https://dash.superagentes.ai/api/user-conversations/export/{conversation_id}',
        headers=headers,
        params=params
    )
    
    if format == 'html':
        return response.text
    else:
        return response.json()
curl --request GET \
  --url 'https://dash.superagentes.ai/api/user-conversations/export/conversation-id-1?format=json' \
  --header 'Authorization: Bearer seu_token_jwt' \
  --header 'Content-Type: application/json'

Exemplo de resposta

{
  "id": "conversation-id-1",
  "title": "Conversa com Cliente",
  "contactName": "Nome do Cliente",
  "phoneNumber": "+5511999999999",
  "channel": "whatsapp",
  "agentName": "Nome do Agente",
  "createdAt": "2024-01-01T00:00:00.000Z",
  "messages": [
    {
      "id": "message-id-1",
      "from": "agent",
      "text": "Olá, como posso ajudar?",
      "timestamp": "2024-01-01T00:00:00.000Z",
      "formattedTimestamp": "01/01/2024 00:00",
      "senderName": "Nome do Agente",
      "attachments": []
    }
  ]
}