Para o sucesso desse tutorial presume-se que o Chatwoot encontra-se instalado e configurado.
Documentação Oficial: http://doc.evolution-api.com/
Git para download: https://github.com/EvolutionAPI/evolution-api
Passo 1 – Baixar e instalar via Docker-Compose o EvolutionAPI
cd
git clone https://github.com/EvolutionAPI/evolution-api.git
- Renomear docker-compose.yaml.example para docker-compose.yaml.example
mv docker-compose.yaml.example docker-compose.yaml
Passo 2 – Configurar o arquivo .env
cd Docker
mv .env.exemple .env
vim .env
- Principais ajustes dentro do arquivo .env são
- Server URL : Endereço e porta do endopint que irá receber instruções de API
- Name: Nome que irá aparecer no WhatsApp do Cliente
- AUTHENTICATION_API_KEY: Senha que irá proteger a API do seu endpoint. Gere uma senha nova. Sugestão de gerador: https://generate-random.org/api-key-generator
# Server URL - Set your application url
SERVER_URL=http://192.168.0.254:8081
# Name that will be displayed on smartphone connection
CONFIG_SESSION_PHONE_CLIENT=CuidadoDigital
## Define a global apikey to access all instances.
### OBS: This key must be inserted in the request header to create an instance.
AUTHENTICATION_API_KEY=Lqxb8hZvimZi2L0OXOxeoy7OmF91tChJjnoC6h5tKejIqQEYikZEmN5gYg3LKiHT
- Levantar o seviço dentro de ~/evolution-api
cd ~/evolution-api
docker-compose up -d
- Teste o serviço com seguinte comando:
# Comando
curl 127.0.0.1:8081
# Resposta esperada
{"status":200,"message":"Welcome to the Evolution API, it is working!","version":"1.5.1"}
Passo 3 – Usando EvolutionAPI
- Criando uma instância
- Ajustar a URL para o seu endpoint
- Ajustar APIKEY: ( a mesma do passo anterior)
- Definir o InstanceName: ( Nome da caixa de entrada que irá aparecer dentro do chatwoot.
- Chatwoot_account_id: Pegar o ID dentro do Chatwoot, a caixa será instalada dentro desse ID
- Chatwoot_token: cndZK3xzxxxxxUNzfxxx8FPx (Pegar o Token dentro do Chatwoot e colar aqui)
- Chatwoot_url: https://app.minhaempresa.com.br/ (Url do Chatwoot)
curl -X POST http://127.0.0.1:8081/instance/create \
-H "apikey: B6D711FCDE4D4120E713976" \
-H "Content-Type: application/json" \
-d '{
"instanceName": "Whatsapp",
"token": "",
"qrcode": true,
"chatwoot_account_id": 1,
"chatwoot_token": "cndZK3pd6safasdfas1seb27oUNzf8FPx",
"chatwoot_url": "https://app.minhaempresa.com.br/",
"chatwoot_sign_msg": true,
"chatwoot_reopen_conversation": true,
"chatwoot_conversation_pending": false
}'
- Ajustando parametros de uma instância
- Obs. O último parametro da URL é nome da caixa postal criada anteriormente.
- reject_call: true ( Utilize esse recurso para rejeitar automaticamente chamadas)
- msg_call: “Não recebemos ligação” ( Se reject_call estiver true uma mensagem será enviada)
- groups_ignore: true ( Ignorar grupos de Whatsapp
- always_online: true ( Mostrar sempre Online
- read_messages: false ( Se false, as mensagens no smartphone aparecerão como não lidas. Se true as mensagens serão marcadas como lida)
- read_status: false ( Ler status)
curl -X POST http://127.0.0.1:8081/settings/set/Whatsapp \
-H "apikey: B6D711FCDE4D4FD5936544120E713976" \
-H "Content-Type: application/json" \
-d '{
"reject_call": false,
"msg_call": "",
"groups_ignore": true,
"always_online": true,
"read_messages": false,
"read_status": false
}'
curl -X DELETE http://127.0.0.1:8081/instance/logout/Whatsapp \
-H "apikey: B6D711FCDE4D4FD5936544120E713976" \
-H "Content-Type: application/json"
curl -X DELETE http://127.0.0.1:8081/instance/delete/Whatsapp \
-H "apikey: B6D711FCDE4D4FD5936544120E713976" \
-H "Content-Type: application/json"
- Buscando Instâncias Ativas
curl -X GET http://127.0.0.1:8081/instance/fetchInstances \
-H "apikey: B6D711FCDE4D4FD5936544120E713976" \
-H "Content-Type: application/json"
- Reiniciando uma instência
curl -X GET http://127.0.0.1:8081/instance/restart/Whatsapp \
-H "apikey: B6D711FCDE4D4FD5936544120E713976" \
-H "Content-Type: application/json"
Você precisa fazer login para comentar.