Criar flow
curl --request POST \
--url https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "agendamento_consulta",
"categories": [
"APPOINTMENT_BOOKING"
],
"flow_json": "{\"version\": \"7.0\", \"routing_model\": {\"WELCOME\": [\"DONE\"], \"DONE\": []}, \"screens\": [{\"id\": \"WELCOME\", \"title\": \"Agendamento\", \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextHeading\", \"text\": \"Escolha um horario\"}, {\"type\": \"Form\", \"name\": \"form\", \"children\": [{\"type\": \"TextInput\", \"name\": \"nome\", \"label\": \"Seu nome\", \"input-type\": \"text\", \"required\": true}, {\"type\": \"DatePicker\", \"name\": \"data\", \"label\": \"Data\"}, {\"type\": \"Footer\", \"label\": \"Continuar\", \"on-click-action\": {\"name\": \"navigate\", \"next\": {\"type\": \"screen\", \"name\": \"DONE\"}, \"payload\": {}}}]}]}}, {\"id\": \"DONE\", \"title\": \"Pronto\", \"terminal\": true, \"success\": true, \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextBody\", \"text\": \"Agendamento confirmado.\"}, {\"type\": \"Footer\", \"label\": \"Fechar\", \"on-click-action\": {\"name\": \"complete\", \"payload\": {}}}]}}]}",
"publish": false
}
'import requests
url = "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows"
payload = {
"name": "agendamento_consulta",
"categories": ["APPOINTMENT_BOOKING"],
"flow_json": "{\"version\": \"7.0\", \"routing_model\": {\"WELCOME\": [\"DONE\"], \"DONE\": []}, \"screens\": [{\"id\": \"WELCOME\", \"title\": \"Agendamento\", \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextHeading\", \"text\": \"Escolha um horario\"}, {\"type\": \"Form\", \"name\": \"form\", \"children\": [{\"type\": \"TextInput\", \"name\": \"nome\", \"label\": \"Seu nome\", \"input-type\": \"text\", \"required\": true}, {\"type\": \"DatePicker\", \"name\": \"data\", \"label\": \"Data\"}, {\"type\": \"Footer\", \"label\": \"Continuar\", \"on-click-action\": {\"name\": \"navigate\", \"next\": {\"type\": \"screen\", \"name\": \"DONE\"}, \"payload\": {}}}]}]}}, {\"id\": \"DONE\", \"title\": \"Pronto\", \"terminal\": true, \"success\": true, \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextBody\", \"text\": \"Agendamento confirmado.\"}, {\"type\": \"Footer\", \"label\": \"Fechar\", \"on-click-action\": {\"name\": \"complete\", \"payload\": {}}}]}}]}",
"publish": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'agendamento_consulta',
categories: ['APPOINTMENT_BOOKING'],
flow_json: '{"version": "7.0", "routing_model": {"WELCOME": ["DONE"], "DONE": []}, "screens": [{"id": "WELCOME", "title": "Agendamento", "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextHeading", "text": "Escolha um horario"}, {"type": "Form", "name": "form", "children": [{"type": "TextInput", "name": "nome", "label": "Seu nome", "input-type": "text", "required": true}, {"type": "DatePicker", "name": "data", "label": "Data"}, {"type": "Footer", "label": "Continuar", "on-click-action": {"name": "navigate", "next": {"type": "screen", "name": "DONE"}, "payload": {}}}]}]}}, {"id": "DONE", "title": "Pronto", "terminal": true, "success": true, "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextBody", "text": "Agendamento confirmado."}, {"type": "Footer", "label": "Fechar", "on-click-action": {"name": "complete", "payload": {}}}]}}]}',
publish: false
})
};
fetch('https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'agendamento_consulta',
'categories' => [
'APPOINTMENT_BOOKING'
],
'flow_json' => '{"version": "7.0", "routing_model": {"WELCOME": ["DONE"], "DONE": []}, "screens": [{"id": "WELCOME", "title": "Agendamento", "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextHeading", "text": "Escolha um horario"}, {"type": "Form", "name": "form", "children": [{"type": "TextInput", "name": "nome", "label": "Seu nome", "input-type": "text", "required": true}, {"type": "DatePicker", "name": "data", "label": "Data"}, {"type": "Footer", "label": "Continuar", "on-click-action": {"name": "navigate", "next": {"type": "screen", "name": "DONE"}, "payload": {}}}]}]}}, {"id": "DONE", "title": "Pronto", "terminal": true, "success": true, "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextBody", "text": "Agendamento confirmado."}, {"type": "Footer", "label": "Fechar", "on-click-action": {"name": "complete", "payload": {}}}]}}]}',
'publish' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows"
payload := strings.NewReader("{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "1122334455667788",
"name": "agendamento_consulta",
"categories": [
"APPOINTMENT_BOOKING"
],
"status": "PUBLISHED",
"endpoint_uri": null,
"validation_errors": []
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Flows (WhatsApp)
Criar flow
Crie um flow a partir do flow_json
POST
/
whatsapp
/
businesses
/
{wabaId}
/
flows
Criar flow
curl --request POST \
--url https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "agendamento_consulta",
"categories": [
"APPOINTMENT_BOOKING"
],
"flow_json": "{\"version\": \"7.0\", \"routing_model\": {\"WELCOME\": [\"DONE\"], \"DONE\": []}, \"screens\": [{\"id\": \"WELCOME\", \"title\": \"Agendamento\", \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextHeading\", \"text\": \"Escolha um horario\"}, {\"type\": \"Form\", \"name\": \"form\", \"children\": [{\"type\": \"TextInput\", \"name\": \"nome\", \"label\": \"Seu nome\", \"input-type\": \"text\", \"required\": true}, {\"type\": \"DatePicker\", \"name\": \"data\", \"label\": \"Data\"}, {\"type\": \"Footer\", \"label\": \"Continuar\", \"on-click-action\": {\"name\": \"navigate\", \"next\": {\"type\": \"screen\", \"name\": \"DONE\"}, \"payload\": {}}}]}]}}, {\"id\": \"DONE\", \"title\": \"Pronto\", \"terminal\": true, \"success\": true, \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextBody\", \"text\": \"Agendamento confirmado.\"}, {\"type\": \"Footer\", \"label\": \"Fechar\", \"on-click-action\": {\"name\": \"complete\", \"payload\": {}}}]}}]}",
"publish": false
}
'import requests
url = "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows"
payload = {
"name": "agendamento_consulta",
"categories": ["APPOINTMENT_BOOKING"],
"flow_json": "{\"version\": \"7.0\", \"routing_model\": {\"WELCOME\": [\"DONE\"], \"DONE\": []}, \"screens\": [{\"id\": \"WELCOME\", \"title\": \"Agendamento\", \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextHeading\", \"text\": \"Escolha um horario\"}, {\"type\": \"Form\", \"name\": \"form\", \"children\": [{\"type\": \"TextInput\", \"name\": \"nome\", \"label\": \"Seu nome\", \"input-type\": \"text\", \"required\": true}, {\"type\": \"DatePicker\", \"name\": \"data\", \"label\": \"Data\"}, {\"type\": \"Footer\", \"label\": \"Continuar\", \"on-click-action\": {\"name\": \"navigate\", \"next\": {\"type\": \"screen\", \"name\": \"DONE\"}, \"payload\": {}}}]}]}}, {\"id\": \"DONE\", \"title\": \"Pronto\", \"terminal\": true, \"success\": true, \"layout\": {\"type\": \"SingleColumnLayout\", \"children\": [{\"type\": \"TextBody\", \"text\": \"Agendamento confirmado.\"}, {\"type\": \"Footer\", \"label\": \"Fechar\", \"on-click-action\": {\"name\": \"complete\", \"payload\": {}}}]}}]}",
"publish": False
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'agendamento_consulta',
categories: ['APPOINTMENT_BOOKING'],
flow_json: '{"version": "7.0", "routing_model": {"WELCOME": ["DONE"], "DONE": []}, "screens": [{"id": "WELCOME", "title": "Agendamento", "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextHeading", "text": "Escolha um horario"}, {"type": "Form", "name": "form", "children": [{"type": "TextInput", "name": "nome", "label": "Seu nome", "input-type": "text", "required": true}, {"type": "DatePicker", "name": "data", "label": "Data"}, {"type": "Footer", "label": "Continuar", "on-click-action": {"name": "navigate", "next": {"type": "screen", "name": "DONE"}, "payload": {}}}]}]}}, {"id": "DONE", "title": "Pronto", "terminal": true, "success": true, "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextBody", "text": "Agendamento confirmado."}, {"type": "Footer", "label": "Fechar", "on-click-action": {"name": "complete", "payload": {}}}]}}]}',
publish: false
})
};
fetch('https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'agendamento_consulta',
'categories' => [
'APPOINTMENT_BOOKING'
],
'flow_json' => '{"version": "7.0", "routing_model": {"WELCOME": ["DONE"], "DONE": []}, "screens": [{"id": "WELCOME", "title": "Agendamento", "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextHeading", "text": "Escolha um horario"}, {"type": "Form", "name": "form", "children": [{"type": "TextInput", "name": "nome", "label": "Seu nome", "input-type": "text", "required": true}, {"type": "DatePicker", "name": "data", "label": "Data"}, {"type": "Footer", "label": "Continuar", "on-click-action": {"name": "navigate", "next": {"type": "screen", "name": "DONE"}, "payload": {}}}]}]}}, {"id": "DONE", "title": "Pronto", "terminal": true, "success": true, "layout": {"type": "SingleColumnLayout", "children": [{"type": "TextBody", "text": "Agendamento confirmado."}, {"type": "Footer", "label": "Fechar", "on-click-action": {"name": "complete", "payload": {}}}]}}]}',
'publish' => false
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows"
payload := strings.NewReader("{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.omni.z-api.io/whatsapp/businesses/{wabaId}/flows")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"agendamento_consulta\",\n \"categories\": [\n \"APPOINTMENT_BOOKING\"\n ],\n \"flow_json\": \"{\\\"version\\\": \\\"7.0\\\", \\\"routing_model\\\": {\\\"WELCOME\\\": [\\\"DONE\\\"], \\\"DONE\\\": []}, \\\"screens\\\": [{\\\"id\\\": \\\"WELCOME\\\", \\\"title\\\": \\\"Agendamento\\\", \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextHeading\\\", \\\"text\\\": \\\"Escolha um horario\\\"}, {\\\"type\\\": \\\"Form\\\", \\\"name\\\": \\\"form\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextInput\\\", \\\"name\\\": \\\"nome\\\", \\\"label\\\": \\\"Seu nome\\\", \\\"input-type\\\": \\\"text\\\", \\\"required\\\": true}, {\\\"type\\\": \\\"DatePicker\\\", \\\"name\\\": \\\"data\\\", \\\"label\\\": \\\"Data\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Continuar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"navigate\\\", \\\"next\\\": {\\\"type\\\": \\\"screen\\\", \\\"name\\\": \\\"DONE\\\"}, \\\"payload\\\": {}}}]}]}}, {\\\"id\\\": \\\"DONE\\\", \\\"title\\\": \\\"Pronto\\\", \\\"terminal\\\": true, \\\"success\\\": true, \\\"layout\\\": {\\\"type\\\": \\\"SingleColumnLayout\\\", \\\"children\\\": [{\\\"type\\\": \\\"TextBody\\\", \\\"text\\\": \\\"Agendamento confirmado.\\\"}, {\\\"type\\\": \\\"Footer\\\", \\\"label\\\": \\\"Fechar\\\", \\\"on-click-action\\\": {\\\"name\\\": \\\"complete\\\", \\\"payload\\\": {}}}]}}]}\",\n \"publish\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "1122334455667788",
"name": "agendamento_consulta",
"categories": [
"APPOINTMENT_BOOKING"
],
"status": "PUBLISHED",
"endpoint_uri": null,
"validation_errors": []
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}{
"error": 123,
"message": "<string>"
}Conceituação
Cria um flow no WABA. Oflow_json é a definição das telas, enviada como string — não como objeto.
Com publish: true o flow já nasce publicado. Sem isso, ele fica em DRAFT, que é o único status em que você ainda pode alterar o flow_json.
Se alguma tela usar a ação
data_exchange, o campo endpoint_uri é obrigatório.A estrutura do
flow_json e a lista de componentes estão na Introdução.Autorizações
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Parâmetros de caminho
ID do WABA (obtido via Listar WABAs)
Exemplo:
"428083093730937"
Corpo
application/json
Nome do flow
Exemplo:
"agendamento_consulta"
Categorias do flow (a Meta usa na revisão)
Opções disponíveis:
SIGN_UP, SIGN_IN, APPOINTMENT_BOOKING, LEAD_GENERATION, CONTACT_US, CUSTOMER_SUPPORT, SURVEY, OTHER Exemplo:
["APPOINTMENT_BOOKING"]
Definição das telas em JSON, enviada como string
URL do seu endpoint, obrigatória apenas para flows com data_exchange
Exemplo:
"https://app.suaempresa.com/flows/callback"
Quando true, publica o flow já na criação
Resposta
Flow criado
ID do flow
Nome do flow
Categorias do flow (a Meta usa na revisão)
Opções disponíveis:
SIGN_UP, SIGN_IN, APPOINTMENT_BOOKING, LEAD_GENERATION, CONTACT_US, CUSTOMER_SUPPORT, SURVEY, OTHER Status de publicação
Opções disponíveis:
DRAFT, PUBLISHED, DEPRECATED, BLOCKED, THROTTLED URL do seu endpoint, obrigatória apenas para flows com data_exchange
Definição das telas em JSON, enviada como string
Pendências de validação devolvidas pela Meta
Show child attributes
Show child attributes