cURL
Copy
curl --request POST \
--url 'https://whatsapp.paaltech.org/api/v1/businesses/presec/automations' \
--header "Authorization: Bearer $PAALCHAT_TOKEN" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"name": "Chase unpaid fees",
"trigger": "date_reached",
"trigger_config": {"field": "fee_due_date", "offset_days": -3},
"conditions": {"all": [{"field": "custom.fee_balance", "op": "gt", "value": 0}]},
"steps": [
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "wait", "days": 3},
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "notify", "data": {"reason": "fees_overdue"}}
]
}'
const response = await fetch('https://whatsapp.paaltech.org/api/v1/businesses/presec/automations', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.PAALCHAT_TOKEN}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Chase unpaid fees",
"trigger": "date_reached",
"trigger_config": {"field": "fee_due_date", "offset_days": -3},
"conditions": {"all": [{"field": "custom.fee_balance", "op": "gt", "value": 0}]},
"steps": [
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "wait", "days": 3},
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "notify", "data": {"reason": "fees_overdue"}}
]
}),
});
const data = await response.json();
console.log(response.status, data);
use Illuminate\Support\Facades\Http;
$response = Http::withToken(env('PAALCHAT_TOKEN'))
->acceptJson()
->post('https://whatsapp.paaltech.org/api/v1/businesses/presec/automations', [
'name' => 'Chase unpaid fees',
'trigger' => 'date_reached',
'trigger_config' => ['field' => 'fee_due_date', 'offset_days' => -3],
'conditions' => ['all' => [['field' => 'custom.fee_balance', 'op' => 'gt', 'value' => 0]]],
'steps' => [
[
'action' => 'send_template',
'template' => 'school_fee_reminder',
'language' => 'en_US',
'parameters' => [
'parent' => 'field:name',
'amount' => 'custom:fee_balance',
'student' => 'custom:ward_name',
'due_date' => 'custom:fee_due_date',
],
],
['action' => 'wait', 'days' => 3],
[
'action' => 'send_template',
'template' => 'school_fee_reminder',
'language' => 'en_US',
'parameters' => [
'parent' => 'field:name',
'amount' => 'custom:fee_balance',
'student' => 'custom:ward_name',
'due_date' => 'custom:fee_due_date',
],
],
['action' => 'notify', 'data' => ['reason' => 'fees_overdue']],
],
]);
$data = $response->json();
import os
import requests
response = requests.post(
"https://whatsapp.paaltech.org/api/v1/businesses/presec/automations",
headers={"Authorization": f"Bearer {os.environ['PAALCHAT_TOKEN']}", "Accept": "application/json"},
json={
"name": "Chase unpaid fees",
"trigger": "date_reached",
"trigger_config": {"field": "fee_due_date", "offset_days": -3},
"conditions": {"all": [{"field": "custom.fee_balance", "op": "gt", "value": 0}]},
"steps": [
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date",
},
},
{"action": "wait", "days": 3},
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date",
},
},
{"action": "notify", "data": {"reason": "fees_overdue"}},
],
},
)
print(response.status_code, response.json())
require 'net/http'
require 'json'
uri = URI('https://whatsapp.paaltech.org/api/v1/businesses/presec/automations')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = "Bearer #{ENV['PAALCHAT_TOKEN']}"
request['Accept'] = 'application/json'
request['Content-Type'] = 'application/json'
request.body = <<~JSON
{
"name": "Chase unpaid fees",
"trigger": "date_reached",
"trigger_config": {"field": "fee_due_date", "offset_days": -3},
"conditions": {"all": [{"field": "custom.fee_balance", "op": "gt", "value": 0}]},
"steps": [
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "wait", "days": 3},
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "notify", "data": {"reason": "fees_overdue"}}
]
}
JSON
response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.code, JSON.parse(response.body)
package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
req, err := http.NewRequest("POST", "https://whatsapp.paaltech.org/api/v1/businesses/presec/automations", strings.NewReader(`{
"name": "Chase unpaid fees",
"trigger": "date_reached",
"trigger_config": {"field": "fee_due_date", "offset_days": -3},
"conditions": {"all": [{"field": "custom.fee_balance", "op": "gt", "value": 0}]},
"steps": [
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "wait", "days": 3},
{
"action": "send_template",
"template": "school_fee_reminder",
"language": "en_US",
"parameters": {
"parent": "field:name",
"amount": "custom:fee_balance",
"student": "custom:ward_name",
"due_date": "custom:fee_due_date"
}
},
{"action": "notify", "data": {"reason": "fees_overdue"}}
]
}`))
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("PAALCHAT_TOKEN"))
req.Header.Set("Accept", "application/json")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))
}