API
5min
através da api, é possível enviar mensagens de texto, áudio, vídeo, documentos e interagir com a plataforma / usuários de forma remota abaixo, os endpoints disponíveis enviar mensagem de texto \<?php $curl = curl init(); curl setopt array($curl, array( curlopt url => 'https //{backend url}/api/messages/send', curlopt returntransfer => true, curlopt encoding => '', curlopt maxredirs => 10, curlopt timeout => 0, curlopt followlocation => true, curlopt http version => curl http version 1 1, curlopt customrequest => 'post', curlopt postfields =>'{ "number" "5511993231592", //telefone em formato whatsapp "openticket" "0", //0 não abre ticket e 1 abre ticket "queueid" "0", // informe o id da fila desejada (se abrir ticket) "body" "teste" }', curlopt httpheader => array( 'content type application/json', 'authorization bearer seutokenaqui' //token cadastrado na conexão ), )); $response = curl exec($curl); curl close($curl); echo $response; retorno com sucesso { "mensagem" "mensagem enviada" } envia mensagem com arquivos \<?php $curl = curl init(); curl setopt array($curl, array( curlopt url => 'https //{backend url}/api/messages/send', curlopt returntransfer => true, curlopt encoding => '', curlopt maxredirs => 10, curlopt timeout => 0, curlopt followlocation => true, curlopt http version => curl http version 1 1, curlopt customrequest => 'post', curlopt postfields => array( 'medias'=> new curlfile('imagem jpeg'), 'number' => '5511993231592', 'openticket' => '0', //0 não abre ticket e 1 abre ticket 'queueid' => '0', // informe o id da fila desejada (se abrir ticket) 'body' => 'teste' // se enviado aparecerá como caption (se abrir ticket) ), curlopt httpheader => array( 'authorization bearer seutokenaqui' //token cadastrado na conexão ), )); $response = curl exec($curl); curl close($curl); echo $response; retorno com sucesso { "mensagem" "mensagem enviada" } encerrar atendimento \<?php $curl = curl init(); curl setopt array($curl, array( curlopt url => 'https //{backend url}/api/messages/finish', curlopt returntransfer => true, curlopt encoding => '', curlopt maxredirs => 10, curlopt timeout => 0, curlopt followlocation => true, curlopt http version => curl http version 1 1, curlopt customrequest => 'post', curlopt postfields =>'{ "companyid" "1", //id da empresa "ticketid" "98" // id do ticket }', curlopt httpheader => array( 'authorization bearer seutokenaqui' //token cadastrado na conexão ), )); $response = curl exec($curl); curl close($curl); echo $response; retorno com sucesso { "res" { "id" 98, "status" "closed", "unreadmessages" 0, "lastmessage" "mensagem de teste", "isgroup" false, "userid" null, "contactid" 1, "whatsappid" 2, "queueid" null, "chatbot" false, "channel" "whatsapp", "queueoptionid" null, "companyid" 1, "uuid" "82291813 86f8 4504 b7d5 c562c6123129", "createdat" "2023 07 25t14 20 59 917z", "updatedat" "2023 08 13t15 56 14 759z" } }