> ## 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.

# Acionar Fluxo de Conversa

> Acionar seu bot para qualquer número de celular

# Acionar Fluxo de Bot

Esta API permite acionar um fluxo de conversa específico do seu bot para qualquer número de telefone via WhatsApp.

## Fluxos de Conversa

Os fluxos de conversa permitem automatizar interações com seus contatos, enviando mensagens pré-definidas e coletando respostas de forma estruturada. Ao acionar um fluxo específico, você pode iniciar uma conversa automatizada com qualquer número de telefone.

## Endpoint da API

<ParamField method="POST" type="string">
  Acionar um fluxo de bot específico para um número de telefone via WhatsApp
</ParamField>

## Parâmetros

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

<ParamField query="phone_number_id" type="string" required>
  Número de telefone da conta do WhatsApp ID
</ParamField>

<ParamField query="bot_flow_unique_id" type="string" required>
  ID único do fluxo do bot
</ParamField>

<ParamField query="phone_number" type="string" required>
  Deve começar com o código do país e apenas caracteres numéricos são permitidos
</ParamField>

## Exemplo de Solicitação

<CodeGroup>
  ```bash POST theme={null}
  curl -X POST \ 
  'https://app.wizebot.com.br/api/v1/whatsapp/trigger-bot' \
  -d 'apiToken=API-KEY' \
  -d 'phone_number_id=PHONE-NUMBER-ID' \
  -d 'bot_flow_unique_id=BOT-FLOW-UNIQUE-ID' \
  -d 'phone_number=PHONE-NUMBER'
  ```
</CodeGroup>

## Exemplo de Resposta

<CodeGroup>
  ```json Sucesso theme={null}
  {
    "status": "1",
    "message": "Bot ha been trigger successfully."
  }
  ```

  ```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/trigger-bot">
  ```json theme={null}
  {
    "apiToken": "SUA_API_KEY_AQUI",
    "phone_number_id": "SEU_PHONE_NUMBER_ID",
    "bot_flow_unique_id": "ID_UNICO_DO_FLUXO",
    "phone_number": "5511999999999"
  }
  ```
</Playground>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
    'https://app.wizebot.com.br/api/v1/whatsapp/trigger-bot' \
    -d 'apiToken=SUA_API_KEY_AQUI' \
    -d 'phone_number_id=SEU_PHONE_NUMBER_ID' \
    -d 'bot_flow_unique_id=ID_UNICO_DO_FLUXO' \
    -d 'phone_number=5511999999999'
  ```

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

  const data = {
    apiToken: 'SUA_API_KEY_AQUI',
    phone_number_id: 'SEU_PHONE_NUMBER_ID',
    bot_flow_unique_id: 'ID_UNICO_DO_FLUXO',
    phone_number: '5511999999999'
  };

  axios.post('https://app.wizebot.com.br/api/v1/whatsapp/trigger-bot', 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/trigger-bot';

  $data = array(
    'apiToken' => 'SUA_API_KEY_AQUI',
    'phone_number_id' => 'SEU_PHONE_NUMBER_ID',
    'bot_flow_unique_id' => 'ID_UNICO_DO_FLUXO',
    'phone_number' => '5511999999999'
  );

  $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": "Bot ha been trigger successfully."
  }
  ```

  ```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 - Fluxo Não Encontrado theme={null}
  {
    "status": "0",
    "message": "Bot flow not found."
  }
  ```
</ResponseExample>
