> ## Documentation Index
> Fetch the complete documentation index at: https://docs.messagefy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Digitação

> Simula o indicador de digitação (typing) em uma conversa

# Digitação

Os comandos **Iniciar Digitação** e **Parar Digitação** controlam o indicador de digitação
("digitando...") que aparece na conversa do contato. Use para simular uma experiência
mais natural antes de enviar uma mensagem.

## Iniciar Digitação

Ativa o indicador de "digitando..." na conversa.

### Requisição

```
POST /api/v1/message/SendCommand
```

```json theme={null}
{
  "channelId": "uuid-do-canal",
  "content": {
    "type": "START_TYPING",
    "commandType": "START_TYPING",
    "to": "5511999887766@s.whatsapp.net"
  }
}
```

### Campos

| Campo | Tipo     | Obrigatório | Descrição                          |
| ----- | -------- | ----------- | ---------------------------------- |
| `to`  | `string` | **Sim**     | JID da conversa (contato ou grupo) |

***

## Parar Digitação

Remove o indicador de "digitando..." da conversa.

### Requisição

```
POST /api/v1/message/SendCommand
```

```json theme={null}
{
  "channelId": "uuid-do-canal",
  "content": {
    "type": "STOP_TYPING",
    "commandType": "STOP_TYPING",
    "to": "5511999887766@s.whatsapp.net"
  }
}
```

### Campos

| Campo | Tipo     | Obrigatório | Descrição                          |
| ----- | -------- | ----------- | ---------------------------------- |
| `to`  | `string` | **Sim**     | JID da conversa (contato ou grupo) |

## Resposta da API

Ambos os comandos retornam:

```json theme={null}
{
  "packageId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
```

<Note>
  Estes comandos não geram webhooks de resposta. O indicador de digitação e exibido
  imediatamente na conversa do contato.
</Note>

## Fluxo recomendado

<Steps>
  <Step title="Iniciar digitação">
    Envie o comando `START_TYPING` para a conversa desejada.
  </Step>

  <Step title="Aguardar">
    Aguarde o tempo desejado (simule o tempo de digitação de uma pessoa real).
  </Step>

  <Step title="Enviar mensagem">
    Envie a mensagem usando o endpoint `/api/v1/message/SendMessage`.
  </Step>

  <Step title="Parar digitação (opcional)">
    O indicador de digitação e removido automaticamente ao enviar a mensagem.
    Use `STOP_TYPING` apenas se decidir não enviar a mensagem.
  </Step>
</Steps>

## Exemplo completo

<CodeGroup>
  ```bash cURL theme={null}
  # Iniciar digitacao
  curl -X POST https://api-dev.messagefy.io/api/v1/message/SendCommand \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: sua-api-key" \
    -d '{
      "channelId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "content": {
        "type": "START_TYPING",
        "commandType": "START_TYPING",
        "to": "5511999887766@s.whatsapp.net"
      }
    }'

  # Aguarde 2-3 segundos, depois envie a mensagem

  # Parar digitacao (opcional)
  curl -X POST https://api-dev.messagefy.io/api/v1/message/SendCommand \
    -H "Content-Type: application/json" \
    -H "X-API-KEY: sua-api-key" \
    -d '{
      "channelId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "content": {
        "type": "STOP_TYPING",
        "commandType": "STOP_TYPING",
        "to": "5511999887766@s.whatsapp.net"
      }
    }'
  ```

  ```python Python theme={null}
  import requests
  import time

  headers = {
      "Content-Type": "application/json",
      "X-API-KEY": "sua-api-key"
  }

  channel_id = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  contact_jid = "5511999887766@s.whatsapp.net"

  # Iniciar digitacao
  requests.post(
      "https://api-dev.messagefy.io/api/v1/message/SendCommand",
      headers=headers,
      json={
          "channelId": channel_id,
          "content": {
              "type": "START_TYPING",
              "commandType": "START_TYPING",
              "to": contact_jid
          }
      }
  )

  # Simular tempo de digitacao
  time.sleep(3)

  # Enviar mensagem (via SendMessage)
  requests.post(
      "https://api-dev.messagefy.io/api/v1/message/SendMessage",
      headers=headers,
      json={
          "channelId": channel_id,
          "content": {
              "type": "TEXT",
              "text": "Olá! Como posso ajudar?",
              "to": {"phoneNumber": "5511999887766"}
          }
      }
  )
  ```

  ```javascript Node.js theme={null}
  const headers = {
    "Content-Type": "application/json",
    "X-API-KEY": "sua-api-key",
  };

  const channelId = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
  const contactJid = "5511999887766@s.whatsapp.net";

  // Iniciar digitacao
  await fetch("https://api-dev.messagefy.io/api/v1/message/SendCommand", {
    method: "POST",
    headers,
    body: JSON.stringify({
      channelId,
      content: {
        type: "START_TYPING",
        commandType: "START_TYPING",
        to: contactJid,
      },
    }),
  });

  // Simular tempo de digitacao
  await new Promise((resolve) => setTimeout(resolve, 3000));

  // Enviar mensagem (via SendMessage)
  await fetch("https://api-dev.messagefy.io/api/v1/message/SendMessage", {
    method: "POST",
    headers,
    body: JSON.stringify({
      channelId,
      content: {
        type: "TEXT",
        text: "Olá! Como posso ajudar?",
        to: { phoneNumber: "5511999887766" },
      },
    }),
  });
  ```
</CodeGroup>

<Tip>
  Use o indicador de digitação para criar uma experiência mais humanizada em chatbots.
  Um atraso de 1 a 3 segundos antes de enviar a resposta simula o comportamento de uma pessoa real.
</Tip>
