> ## Documentation Index
> Fetch the complete documentation index at: https://help.wizebot.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Obter Conversa WhatsApp

> Obter conversa de assinante específico do WhatsApp

# Obter Conversa de Assinante

Esta API permite obter o histórico de conversas com um assinante específico através do WhatsApp.

## Histórico de Conversas

O histórico de conversas permite visualizar todas as mensagens trocadas entre a sua conta do WhatsApp Business e um número de telefone específico. Isso é útil para análise de interações, suporte ao cliente e acompanhamento de conversas.

## Endpoint da API

<ParamField method="POST" type="string">
  Obter histórico de conversas com um assinante específico via WhatsApp
</ParamField>

## Parâmetros

<ParamField query="apiToken" type="string" required>
  Sua chave de API
</ParamField>

<ParamField query="phone_number_id" type="string" required>
  Seu número de telefone do WhatsApp
</ParamField>

<ParamField query="phone_number" type="string" required>
  Número de telefone do assinante
</ParamField>

<ParamField query="limit" type="number" required>
  Buscar número da mensagem da conversa
</ParamField>

<ParamField query="offset" type="number">
  Deslocamento de paginação
</ParamField>

## Exemplo de Solicitação

<CodeGroup>
  ```bash POST theme={null}
  curl -X POST \ 
  'https://app.wizebot.com.br/api/v1/whatsapp/get/conversation' \
  -d 'apiToken=API-KEY' \
  -d 'phone_number_id=PHONE-NUMBER-ID' \
  -d 'phone_number=PHONE-NUMBER' \
  -d 'limit=10' \
  -d 'offset=1'
  ```
</CodeGroup>

## Exemplo de Resposta

<CodeGroup>
  ```json Sucesso theme={null}
  {
    "status": "1",
    "message": [
      {
        "id": 8443,
        "whatsapp_bot_subscriber_subscriber_id": "88017XXXXX-23",
        "whatsapp_bot_id": 23,
        "sender": "bot",
        "agent_name": null,
        "message_content": "{\"delay_in_reply\":0,\"messaging_product\":\"whatsapp\",\"recipient_type\":\"individual\",\"to\":\"88017XXXX9003\",\"type\":\"interactive\",\"interactive\":{\"header\":{\"type\":\"text\",\"text\":\"Order gateway\"},\"body\":{\"text\":\"How would you like to purchase it?\"},\"type\":\"button\",\"action\":{\"buttons\":[{\"type\":\"reply\",\"reply\":{\"id\":\"5lvomLOuENXIe6D::gPeAiDDmVQR_jTR\",\"title\":\"Paypal pay\"}},{\"type\":\"reply\",\"reply\":{\"id\":\"YES_START_CHAT_WITH_HUMAN::CBaLoC4yTMyIljZ\",\"title\":\"COD\"}}]}}}",
        "conversation_time": "2024-07-28 13:21:03",
        "wa_message_id": "wamid.HBgNODgwMTcyMzMwOTAwMxUCABEYEjlGQkY3MEFEMEVGODhCNDkxNQA=",
        "reaction_data": null,
        "message_status": null,
        "delivery_status_updated_at": "2024-07-28 13:21:03",
        "failed_reason": ""
      }
    ]
  }
  ```

  ```json Erro theme={null}
  {
    "status": "0",
    "message": "Invalid API Key."
  }
  ```
</CodeGroup>

## Teste a API

<Note>
  Para testar esta API, você precisará de sua chave API (apiToken) que pode ser encontrada no painel da WizeBot em Configurações > API.
</Note>

<Playground method="POST" endpoint="https://app.wizebot.com.br/api/v1/whatsapp/get/conversation">
  ```json theme={null}
  {
    "apiToken": "SUA_API_KEY_AQUI",
    "phone_number_id": "SEU_PHONE_NUMBER_ID",
    "phone_number": "NUMERO_DO_ASSINANTE",
    "limit": 10,
    "offset": 0
  }
  ```
</Playground>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
    'https://app.wizebot.com.br/api/v1/whatsapp/get/conversation' \
    -d 'apiToken=SUA_API_KEY_AQUI' \
    -d 'phone_number_id=SEU_PHONE_NUMBER_ID' \
    -d 'phone_number=NUMERO_DO_ASSINANTE' \
    -d 'limit=10' \
    -d 'offset=0'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const data = {
    apiToken: 'SUA_API_KEY_AQUI',
    phone_number_id: 'SEU_PHONE_NUMBER_ID',
    phone_number: 'NUMERO_DO_ASSINANTE',
    limit: 10,
    offset: 0
  };

  axios.post('https://app.wizebot.com.br/api/v1/whatsapp/get/conversation', data)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error('Erro:', error);
  });
  ```

  ```php PHP theme={null}
  <?php
  $url = 'https://app.wizebot.com.br/api/v1/whatsapp/get/conversation';

  $data = array(
    'apiToken' => 'SUA_API_KEY_AQUI',
    'phone_number_id' => 'SEU_PHONE_NUMBER_ID',
    'phone_number' => 'NUMERO_DO_ASSINANTE',
    'limit' => 10,
    'offset' => 0
  );

  $options = array(
    'http' => array(
      'header'  => "Content-type: application/x-www-form-urlencoded\r\n",
      'method'  => 'POST',
      'content' => http_build_query($data)
    )
  );

  $context  = stream_context_create($options);
  $result = file_get_contents($url, false, $context);

  echo $result;
  ?>
  ```
</RequestExample>

<ResponseExample>
  ```json Sucesso theme={null}
  {
    "status": "1",
    "message": [
      {
        "id": 8443,
        "whatsapp_bot_subscriber_subscriber_id": "88017XXXXX-23",
        "whatsapp_bot_id": 23,
        "sender": "bot",
        "agent_name": null,
        "message_content": "{\"delay_in_reply\":0,\"messaging_product\":\"whatsapp\",\"recipient_type\":\"individual\",\"to\":\"88017XXXX9003\",\"type\":\"interactive\",\"interactive\":{\"header\":{\"type\":\"text\",\"text\":\"Order gateway\"},\"body\":{\"text\":\"How would you like to purchase it?\"},\"type\":\"button\",\"action\":{\"buttons\":[{\"type\":\"reply\",\"reply\":{\"id\":\"5lvomLOuENXIe6D::gPeAiDDmVQR_jTR\",\"title\":\"Paypal pay\"}},{\"type\":\"reply\",\"reply\":{\"id\":\"YES_START_CHAT_WITH_HUMAN::CBaLoC4yTMyIljZ\",\"title\":\"COD\"}}]}}}",
        "conversation_time": "2024-07-28 13:21:03",
        "wa_message_id": "wamid.HBgNODgwMTcyMzMwOTAwMxUCABEYEjlGQkY3MEFEMEVGODhCNDkxNQA=",
        "reaction_data": null,
        "message_status": null,
        "delivery_status_updated_at": "2024-07-28 13:21:03",
        "failed_reason": ""
      }
    ]
  }
  ```

  ```json Erro - API Key Inválida theme={null}
  {
    "status": "0",
    "message": "Invalid API Key."
  }
  ```

  ```json Erro - Parâmetros Inválidos theme={null}
  {
    "status": "0",
    "message": "Missing required parameters."
  }
  ```

  ```json Erro - Assinante Não Encontrado theme={null}
  {
    "status": "0",
    "message": "Subscriber not found."
  }
  ```
</ResponseExample>
