NAV Navbar
php

Click2Wasap Multics API

Message

Send Message

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-text';
$data = array(
  "number"  => '60123456789',
  "message" => 'Click2Wasap Test Message!'
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-text

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number.
message text to be sent.

Response

JSON Attributes Description
status status code.
message message status.
data data response.
device_id device id.
number target number.
message message to be sent.
chat_id chat_id
type type message
from_me message from me
from_group message from group
api message from api
created_at message created_at
updated_at message updated_at
id data id

Send Message Image/File URL

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-media-url';
$data = array(
  "number"  => '60123456789',
  "message" => 'Click2Wasap Test Message!'
  "image_url" => 'https://app.click2wasap.com/wp-content/uploads/2021/07/cropped-Click2Wasap-wo-Shadow512-1.png',
  "type" => 'image' // text, image, document 
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message with image/file url.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-media-url

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number.
message text to be sent.
media_url image url to be sent.
type type media to be sent. ex: text/image/document

Response

JSON Attributes Description
status status code.
message message status.
data data response.
id device key.
device_id device id.
message message to be sent.
number target number.
type type message
updated_at message updated_at

Send Message Image/File URL

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-media';
$data = array(
  "number"  => '60123456789',
  "message" => 'Click2Wasap Test Message!'
  "image" => 'Attch your image file!',
  "type" => 'image' // text, image, document 
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message with image/file.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-media

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number.
message text to be sent.
media attach your image file to be sent.
type type media to be sent. ex: text/image/document

Response

JSON Attributes Description
status status code.
message message status.
data data response.
id device key.
device_id device id.
message message to be sent.
number target number.
type type message
updated_at message updated_at

Message Group

Send Message Group

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-text';
$data = array(
  "number"  => '60123456789-16219290xx', // use this api group list
  "message" => 'Click2Wasap Test Message!',
  "group" => 1 // 1 = true, 0 = false
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789-16219290xx",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message to group.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-text

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number. use this api group list
message text to be sent.
group message send to group.

Response

JSON Attributes Description
status status code.
message message status.
data data response.
device_id device id.
number target number.
message message to be sent.
chat_id chat_id
type type message
from_me message from me
from_group message from group
api message from api
created_at message created_at
updated_at message updated_at
id data id

Send Message Group Image/File URL

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-media-url';
$data = array(
  "number"  => '60123456789-16219290xx', // use this api group list
  "message" => 'Click2Wasap Test Message!',
  "group" => 1, // 1 = true, 0 = false
  "media_url" => 'https://app.click2wasap.com/wp-content/uploads/2021/07/cropped-Click2Wasap-wo-Shadow512-1.png',
  "type" => 'image' // text, image, document
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789-16219290xx",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message to group with image/file url.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-media-url

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number. use this api group list
message text to be sent.
image_url image url to be send to group.
type type file to be send to group. ex: text/image/document
group type send, if grup set 1, if personal chat set 0, or remove this param

Response

JSON Attributes Description
status status code.
message message status.
data data response.
id device_key.
device_id device id.
message message to be sent.
number target number.
type type message
updated_at message updated_at

Send Message Group Image/File

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/send-media';
$data = array(
  "number"  => '60123456789-16219290xx', // use this api group list
  "message" => 'Click2Wasap Test Message!',
  "group" => 1, // 1 = true, 0 = false
  "media_url" => 'Attach your image file!',
  "type" => 'image' // text, image, document
);
$data_string = http_build_query($data,1);

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "device-key: $device_key",
    'Content-Type: application/x-www-form-urlencoded'
));
echo $result = curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "288b996f-69da-4d57-815e-fdb7342ba012",
        "device_id": "4",
        "message": "Click2Wasap Test Message!",
        "number": "60123456789-16219290xx",
        "type": "text",
        "updated_at": "2021-06-04 01:35:53"
    }
}

This endpoint is used to send text message to group with image/file.

HTTP Request

POST https://node.click2wasap.com/api/srv1/send-media

HTTP Headers

Parameter Value
device-key devicekey
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
number Client's whatsapp number. use this api group list
message text to be sent.
image attach your image file to be send to group.
type type file to be send to group. ex: text/image/document
group type send, if grup set 1, if personal chat set 0, or remove this param

Response

JSON Attributes Description
status status code.
message message status.
data data response.
id device_key.
device_id device id.
message message to be sent.
number target number.
type type message
updated_at message updated_at

Group List

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$url='https://node.click2wasap.com/api/srv1/groups';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'device-key: '.$device_key
));
echo $res=curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": [
        {
            "id": "d8b84015-6440-4162-a5cc-42d7ea499105",
            "number": "60123456789-16182195xx",
            "name": "Test grup"
        },
        {
            "id": "bb651d09-3961-4472-b858-abcf0ea66d71",
            "number": "60123456789-16219290xx",
            "name": "Test Multics"
        }
    ]
}

This endpoint is used to get group list.

HTTP Request

GET https://node.click2wasap.com/api/srv1/groups

HTTP Headers

Parameter Value
device-key devicekey

Response

JSON Attributes Description
status status code.
message message status.
data data response.
id data id
number group number.
name group name.

Chat History

Sample Script

$device_key='db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx'; //this is demo device_key please change with your own device_key
$license = "602dc37xxxxx";
$data = [
  'start_date'    => "2021-06-03",
  'end_date'      => "2021-06-04",
  'search'        => '',
  'order'         => 'asc', // asc/desc
  'page'          => 1,
  'per_page'      => 20
];
$data_string = http_build_query($data);

// $data_string is optional
$url="https://node.click2wasap.com/api/srv1/history-chat/$license?$data_string";

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'device-key: '.$device_key
));
echo $res=curl_exec($ch);
curl_close($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": [
        {
            "id": "092bb5d6-500b-4db5-a330-c977d8c41e82",
            "msg_id": "3EB0B9B2FCAE",
            "user_id": null,
            "chat_id": "d5dbb1fd-f67c-46a1-8e69-a499095acf03",
            "device_id": "4",
            "number": "60123456789",
            "name": "Jhon Doe",
            "from_group": false,
            "from_me": true,
            "from_story": false,
            "message": "hello there",
            "media_url": null,
            "type": "text",
            "reply_for": null,
            "failed_reason": null,
            "timestamp": "2021-06-01T06:53:36.000Z",
            "status": "DELIVERED",
            "api": true,
            "created_at": "2021-06-01 06:53:36",
            "updated_at": "2021-06-01 06:53:39"
        }
    ],
    "paginate": {
        "total": "1",
        "perPage": 20,
        "page": 1,
        "lastPage": 1
    }
}

This endpoint is used to get history chat.

HTTP Request

GET https://node.click2wasap.com/api/srv1/history-chat/602dc37xxxxx?start_date=2021-06-01&end_date=2021-06-03&search=&order=asc&page=1&per_page=20

HTTP Headers

Parameter Value
device-key device key

HTTP query

Parameter Description
start_date Start date
end_date End date
search Search some message
order Sort history by asc or desc
page Page number
per_page Limit data in 1 page

Response

JSON Attributes Description
status Status code.
message Message status.
data Data response.
id Data id.
msg_id Message id.
user_id Message user_id
chat_id Chat ID
device_id Device ID
number Target number
name Target name
from_group Message from group
from_me Message from me
from_story Message from story
message Message text
media_url Media_url if send media
type Message type
reply_for Message reply_for
failed_reason Message failed_reason
timestamp Message timestamp
status Message status
- DELIVERED
- PENDING
- SENT
- FAILED
api Message from api
created_at Message created_at
updated_at Message updated_at
paginate Data pagination
total Total message
perPage Total per page
page Current page
lastPage Last page

Bot

Set Bot

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$data = array(
    "keyword" => "hey",
    "type" => "exact match", // 'exact match', 'start with', 'contain'
    "response" => "hello"
);

$data_string = http_build_query($data);
$url = 'https://node.click2wasap.com/api/srv1/bots';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key,
    'Content-Type: application/x-www-form-urlencoded'
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "keyword": "hey",
        "type": "exact match",
        "response": "hello",
        "created_at": "2021-06-09 03:58:32",
        "updated_at": "2021-06-09 03:58:32",
        "id": "6"
    }
}

This endpoint is used to add bot.

HTTP Request

POST https://node.click2wasap.com/api/srv1/bots

POST Headers

Parameter Description
device-key Device Key
Content-Type application/x-www-form-urlencoded

POST Parameters

Parameter Description
keyword Keywoard message from sender
type Bot type
- exact match, Keyword equals input
- start with, Keyword is similar to the beginning of the input
- contain, Keyword is similar to what is in the input
response Response message sent to sender

Response

Parameter Description
status Status code
message Message status
data Data sent to api
keyword Data keyword sent to api
type Data type sent to api
response Data response sent to api
created_at Data created_at
updated_at Data updated_at
id Data ID
paginate Data pagination
total Total message
perPage Total per page
page Current page
lastPage Last page

Get Bot

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$data = array(
    "page" => 1
);

$data_string = http_build_query($data);
$url = 'https://node.click2wasap.com/api/srv1/bots';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key,
    'Content-Type: application/x-www-form-urlencoded'
));

echo $res = curl_exec($ch);


Response:

{
    "status": 200,
    "message": "Success!",
    "data": [
        {
            "id": "1",
            "sender": null,
            "keyword": "hey",
            "type": "exact match",
            "response": "hello",
            "created_at": "2021-06-09 03:58:32",
            "updated_at": "2021-06-09 03:58:32",
            "case_sensitive": null,
            "personal_only": null
        }
    ],
    "paginate": {
        "total": "1",
        "perPage": 20,
        "page": 1,
        "lastPage": 1
    }
}

This endpoint is used to get bot.

HTTP Request

GET https://node.click2wasap.com/api/srv1/bots

HTTP Headers

Parameter Description
device-key Device Key
Content-Type application/x-www-form-urlencoded

HTTP Query

Parameter Description
page Page number

Response

Parameter Description
status Status code
message Message status
data Data sent to api
id Data ID
sender Number sender
keyword Data keyword sent to api
type Data type sent to api
response Data response sent to api
created_at Data created_at
updated_at Data updated_at
case_sensitive Data case_sensitive
personal_only Data personal_only

Update Bot

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$data = array(
    "keyword" => "hey",
    "type" => "exact match", // 'exact match', 'start with', 'contain'
    "response" => "hello"
);
$id = 1; // id bot from api get bot

$data_string = http_build_query($data);
$url = 'https://node.click2wasap.com/api/srv1/bots/'.$id;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key,
    'Content-Type: application/x-www-form-urlencoded'
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "1",
        "sender": "60123456789",
        "keyword": "hey",
        "type": "exact match",
        "response": "hello",
        "created_at": "2021-06-10 01:34:40",
        "updated_at": "2021-06-10 01:36:55",
        "case_sensitive": null,
        "personal_only": null,
        "device_id": "4"
    }
}

This endpoint is used to update bot.

HTTP Request

PUT https://node.click2wasap.com/api/srv1/bots/$id

HTTP Headers

Parameter Description
device-key Device Key
Content-Type application/x-www-form-urlencoded

PUT Parameters

Parameter Description
keyword Keywoard message from sender
type Bot type
- exact match, Keyword equals input
- start with, Keyword is similar to the beginning of the input
- contain, Keyword is similar to what is in the input
response Response message sent to sender

Response

Parameter Description
status Status code
message Message status
data Data sent to api
id Data ID
sender Data Sender
keyword Data keyword sent to api
type Data type sent to api
response Data response sent to api
created_at Data created_at
updated_at Data updated_at
case_sensitive Data case_sensitive
personal_only Data personal_only
device_id Data device_id

Delete Bot

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$id = 1; // id bot from api get bot

$url = 'https://node.click2wasap.com/api/srv1/bots/'.$id;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "1",
        "sender": "60123456789",
        "keyword": "hey",
        "type": "exact match",
        "response": "hello",
        "created_at": "2021-06-10 01:34:40",
        "updated_at": "2021-06-10 01:36:55",
        "case_sensitive": null,
        "personal_only": null,
        "device_id": "4"
    }
}

This endpoint is used to delete bot.

HTTP Request

DELETE https://node.click2wasap.com/api/srv1/bots/$id

HTTP Headers

Parameter Description
device-key Device Key

POST Parameters

Parameter Description
keyword Keywoard message from sender
type Bot type
- exact match, Keyword equals input
- start with, Keyword is similar to the beginning of the input
- contain, Keyword is similar to what is in the input
response Response message sent to sender

Response

Parameter Description
status Status code
message Message status
data Data sent to api
id Data ID
sender Data Sender
keyword Data keyword sent to api
type Data type sent to api
response Data response sent to api
created_at Data created_at
updated_at Data updated_at
case_sensitive Data case_sensitive
personal_only Data personal_only
device_id Data device_id

Web Hook

Add Webhook

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$data = array(
    "name"      => "example",
    "url"       => "yourwebsite.com/listen.php",
    "qrcode"    => false,   // true/false
    "paired"    => false,   // true/false
    "unpaired"  => false,   // true/false
    "battery"   => false,   // true/false
    "message"   => true,    // true/false
    "misscall"  => false    // true/false
);
$data_string = json_encode($data,1);

$url = 'https://node.click2wasap.com/api/srv1/device/webhook';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key,
    'Content-Type: application/json'
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "name": "example",
        "url": "yourwebsite.com/listen.php",
        "qrcode": false,
        "paired": false,
        "unpaired": false,
        "battery": false,
        "message": true,
        "misscall": false,
        "device_id": "4",
        "created_at": "2021-06-10 05:10:38",
        "updated_at": "2021-06-10 05:10:38",
        "id": "4"
    }
}

This endpoint is used to add webhook.

HTTP Request

POST https://node.click2wasap.com/api/srv1/device/webhook

HTTP Headers

Parameter Description
device-key Device Key
Content-Type application/json

POST Parameters

Parameter Description
name Webhook name
url Webhook url
qrcode Webhook send data on event qrcode value true/false
paired Webhook send data on event paired value true/false
unpaired Webhook send data on event unpaired value true/false
battery Webhook send data on event battery value true/false
message Webhook send data on event message value true/false
misscall Webhook send data on event misscall value true/false

Response

Parameter Description
status Status code
message Message status
data Data sent to api
name Data name webhook
url Data url webhook
qrcode Data qrcode webhook
paired Data paired webhook
unpaired Data unpaired webhook
battery Data battery webhook
message Data message webhook
misscall Data misscall webhook
device_id Data device_id webhook
created_at Data created_at webhook
updated_at Data updated_at webhook
id Data id webhook

Get Webhook

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$url = 'https://node.click2wasap.com/api/srv1/device/webhook';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": [
        {
            "name": "example",
            "url": "yourwebsite.com/listen.php",
            "qrcode": false,
            "paired": false,
            "unpaired": false,
            "battery": false,
            "message": true,
            "misscall": false,
            "device_id": "4",
            "created_at": "2021-06-10 05:10:38",
            "updated_at": "2021-06-10 05:10:38",
            "id": "4"
        }
    ]
}

This endpoint is used to get webhook.

HTTP Request

GET https://node.click2wasap.com/api/srv1/device/webhook

HTTP Headers

Parameter Description
device-key Device Key

Response

Parameter Description
status Status code
message Message status
data Data sent to api
name Data name webhook
url Data url webhook
qrcode Data qrcode webhook
paired Data paired webhook
unpaired Data unpaired webhook
battery Data battery webhook
message Data message webhook
misscall Data misscall webhook
device_id Data device_id webhook
created_at Data created_at webhook
updated_at Data updated_at webhook
id Data id webhook

Update Webhook

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';
$id = 1; // id webhook from api get webhook
$data = array(
    "name"      => "example",
    "url"       => "yourwebsite.com/listen.php",
    "qrcode"    => false,   // true/false
    "paired"    => false,   // true/false
    "unpaired"  => false,   // true/false
    "battery"   => false,   // true/false
    "message"   => true,    // true/false
    "misscall"  => false    // true/false
);
$data_string = json_encode($data,1);

$url = 'https://node.click2wasap.com/api/srv1/device/webhook/'.$id;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key,
    'Content-Type: application/json'
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "id": "4",
        "device_id": "4",
        "name": "sipu-sipu",
        "url": "sipu-sipu.com",
        "qrcode": false,
        "paired": false,
        "unpaired": false,
        "battery": true,
        "message": true,
        "misscall": false,
        "created_at": "2021-06-10 05:10:38",
        "updated_at": "2021-06-10 07:56:11"
    }
}

This endpoint is used to add webhook.

HTTP Request

PUT https://node.click2wasap.com/api/srv1/device/webhook/$id

HTTP Headers

Parameter Description
device-key Device Key
Content-Type application/json

POST Parameters

Parameter Description
name Webhook name
url Webhook url
qrcode Webhook send data on event qrcode value true/false
paired Webhook send data on event paired value true/false
unpaired Webhook send data on event unpaired value true/false
battery Webhook send data on event battery value true/false
message Webhook send data on event message value true/false
misscall Webhook send data on event misscall value true/false

Response

Parameter Description
status Status code
message Message status
data Data sent to api
id Data id webhook
device_id Data device_id webhook
name Data name webhook
url Data url webhook
qrcode Data qrcode webhook
paired Data paired webhook
unpaired Data unpaired webhook
battery Data battery webhook
message Data message webhook
misscall Data misscall webhook
device_id Data device_id webhook
created_at Data created_at webhook
updated_at Data updated_at webhook

Delete Webhook

Sample script

$device_key = 'db63f5inihanyakeydummycf083dd3ffd025d672e255xxxxx';

$id = 1; // id webhook from api get webhook
$url = 'https://node.click2wasap.com/api/srv1/device/webhook/'.$id;

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 360);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'device-key: '.$device_key
));

echo $res = curl_exec($ch);

Response:

{
    "status": 200,
    "message": "Success!",
    "data": {
        "name": "example",
        "url": "yourwebsite.com/listen.php",
        "qrcode": false,
        "paired": false,
        "unpaired": false,
        "battery": false,
        "message": true,
        "misscall": false,
        "device_id": "4",
        "created_at": "2021-06-10 05:10:38",
        "updated_at": "2021-06-10 05:10:38",
        "id": "4"
    }
}

This endpoint is used to delete webhook.

HTTP Request

DELETE https://node.click2wasap.com/api/srv1/device/webhook/$id

HTTP Headers

Parameter Description
device-key Device Key

POST Parameters

Parameter Description
id Webhook id

Response

Parameter Description
status Status code
message Message status
data Data sent to api
name Data name webhook
url Data url webhook
qrcode Data qrcode webhook
paired Data paired webhook
unpaired Data unpaired webhook
battery Data battery webhook
message Data message webhook
misscall Data misscall webhook
device_id Data device_id webhook
created_at Data created_at webhook
updated_at Data updated_at webhook
id Data id webhook

Get Data

Sample PHP Script for Listening data:

$json = file_get_contents('php://input');
$data = json_decode($json);

file_put_contents("listen.txt", print_r($data,1));

Format data from webhook:


stdClass Object
(
    [event] => message
    [name] => click2wasap    [data] => stdClass Object
        (
            [msg_id] => 3EB0B2C3DBC4C8442E48
            [device_id] => 1
            [name] => Admin
            [number] => 60123456789\n
            [from_me] =>
            [from_group] =>
            [from_story] =>
            [chat_id] => d5dbb1fd-f67c-46a1-8e69-a499095acf03
            [user_id] =>
            [status] => DELIVERED
            [type] => text
            [timestamp] => 2021-06-23T03:18:44+00:00
            [message] => o
            [created_at] => 2021-06-23 03:18:45
            [updated_at] => 2021-06-23 03:18:45
            [id] => 225d29b7-d126-4d7d-98c0-75a0763d665d
            [quoted] =>
            [chat] => stdClass Object
                (
                    [user_id] =>
                )

        )

)

This endpoint is used to get data webhook.

Google Form

Google Form Integrate Click2Wasap Addon

Copy this script to google form add-on script editor.



  var ADDON_TITLE = "Click2Wasap"; function onOpen(e) { FormApp.getUi().createAddonMenu().addItem("Click2Wasap Settings", "showSidebar").addItem("About", "showAbout").addToUi(); } function onInstall(e) { onOpen(e); } function setTrigger() { adjustFormSubmitTrigger(); var text = "Trigger is ready, please refresh the page to get started"; var ui = HtmlService.createHtmlOutput(text).setWidth(420).setHeight(270); FormApp.getUi().showModalDialog(ui, "Set Trigger"); } function unsetTrigger() { deleteSubmitTrigger(); var text = "Trigger is unset, please refresh the page to finish the process"; var ui = HtmlService.createHtmlOutput(text).setWidth(420).setHeight(270); FormApp.getUi().showModalDialog(ui, "Unset Trigger"); } function cekTrigger() { var form = FormApp.getActiveForm(); allTriggers = ScriptApp.getUserTriggers(form); for (var i = 0; i < allTriggers.length; i++) { if (allTriggers[i].getEventType() == ScriptApp.EventType.ON_FORM_SUBMIT) { return true; } else { return false; } } } function deleteSubmitTrigger() { var allTriggers = ScriptApp.getProjectTriggers(); var form = FormApp.getActiveForm(); allTriggers = ScriptApp.getUserTriggers(form); for (var i = 0; i < allTriggers.length; i++) { ScriptApp.deleteTrigger(allTriggers[i]); Logger.log(allTriggers[i]); } } function showSidebar(e) { var btnTriggers = ""; if (cekTrigger()) { btnTriggers = '<span style="color:green"> Trigger is already set</span>'; } else { btnTriggers = `<button class="create" id="setTriggers" onclick="setTrigger()">Set Trigger</button>`; } var ui = HtmlService.createTemplate( `<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <!-- <div class="sidebar"> --> <!-- Tab links --> <div class="tab"> <button class="tablinks active" onclick="openTab(event, 'Settings')">Settings</button> <button class="tablinks" onclick="openTab(event, 'Client')">Client</button> <button class="tablinks" onclick="openTab(event, 'Admin')">Admin</button> </div> <!-- Tab content --> <div id="Settings" class="tabcontent" style="display: block;"> <div class="block form-group"> <label for="integrasi">Type <span style="color: red;">*</span></label> <select id="integrasi"> <option value="">-- Select --</option> <option value="click2wasapmultics">Click2Wasap Multics</option> </select> </div> <div class="form-group"> <label for="key">Device Key <span style="color: red;">*</span></label> <input type="text" id="key" name="key" placeholder="Ex: 6d076e2c-550c-4233-9ba5-09eb536xxxxx.." /> </div> <div class="form-group" id="button-bar" style="margin: 15px 0 5px;"> <button class="action" id="save">Save</button> ` + btnTriggers + ` </div> </div> <div id="Client" class="tabcontent"> <div class="clientNotifyForm"> <input type="checkbox" id="clientNotify" /> <label for="clientNotify">Send wa to client?</label></div> <div id="clientOptions"> <div class="form-group"> <label for="no_wa">No Wa</label> <select id="no_wa"> <option value="">-- Select --</option> </select> </div> <div class="form-group"> <label for="template">Template</label> <textarea name="template" id="template" rows="7" placeholder="Ex: {hi|hello}, [Name] and your number : [No Wa]..."></textarea> </div> </div> <div class="form-group" id="client-button-bar" style="margin: 15px 0 5px;"><button class="action" id="clientSave">Save</button></div> </div> <div id="Admin" class="tabcontent"> <div class="adminNotifyForm"><input type="checkbox" id="adminNotify" /> <label for="adminNotify">Send wa to admin?</label></div> <div id="adminOptions"> <div class="form-group"><label for="noWaAdmin">No Wa</label> <input type="text" id="noWaAdmin" placeholder="Ex: 60xxx, 60xxx" /></div> <div class="form-group"><label for="templateAdmin">Template</label> <textarea name="templateAdmin" id="templateAdmin" rows="7" placeholder="Ex: {hi|hello}, [Name] and your number : [No Wa]..."></textarea></div> </div> <div class="form-group" id="admin-button-bar" style="margin: 15px 0 5px;"><button class="action" id="adminSave">Save</button></div> </div> <!-- </div> --> <div class="sidebar bottom"> <a href="https://click2wasap.com"> <img alt="Add-on logo" class="logo" width="30" style="margin-bottom: -0.7em;" src="https://click2wasap.com/wp-content/uploads/2021/06/logo-click2wasap-500x500-1-50x50.png" /> </a> <span class="gray branding-text">Add-on Notifications by <a href="https://click2wasap.com">Click2Wasap</a></span> </div> <link rel="stylesheet" href="https://ssl.gstatic.com/docs/script/css/add-ons1.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> <style> .form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px; margin: 3px 0 8px; } .success { color: rgb(5, 185, 11); } .tab { overflow: hidden; border: 1px solid #ccc; background-color: #f1f1f1; } .tab button { background-color: inherit; float: left; border: none; outline: none; cursor: pointer; padding: 14px 16px; transition: 0.3s; } .tab button:hover { background-color: #ddd; } .tab button.active { background: #ccc; box-shadow: none; } .tabcontent { display: none; padding: 6px 12px; border-top: none; } .tabcontent { animation: fadeEffect 1s; } .tablinks { height: 38px !important; padding: 4px !important; margin: 0 !important; border-radius: 0 !important; border: 0 !important; } @keyframes fadeEffect { from { opacity: 0; } to { opacity: 1; } } .adminNotifyForm, .clientNotifyForm { margin-bottom: 8px; } #adminOptions, #clientOptions { display: none; } </style> <script> $(function () { $("#Settings").click(); $("#save, #adminSave, #clientSave").on("click", saveSettingToServer); $("input, select, textarea").on("click", removeStatus); getData(); changeLabel(); }); $("#integrasi").on("change", function () { changeLabel(); }); $("#adminNotify").click(toggleadminNotify); $("#clientNotify").click(toggleclientNotify); function openTab(evt, cityName) { var i, tabcontent, tablinks; tabcontent = document.getElementsByClassName("tabcontent"); for (i = 0; i < tabcontent.length; i++) { tabcontent[i].style.display = "none"; } tablinks = document.getElementsByClassName("tablinks"); for (i = 0; i < tablinks.length; i++) { tablinks[i].className = tablinks[i].className.replace(" active", ""); } document.getElementById(cityName).style.display = "block"; evt.currentTarget.className += " active"; } function getData() { google.script.run.withSuccessHandler(loadSettings).withFailureHandler(showStatus).withUserObject($("#button-bar").get()).getSettings(); } function loadSettings(settings) { $("#integrasi").val(settings.integrasi); $("#key").val(settings.key); $("#template").text(settings.template); $("#noWaAdmin").val(settings.noWaAdmin); $("#templateAdmin").text(settings.templateAdmin); if (settings.adminNotify === "true") { $("#adminNotify").prop("checked", true); $("#adminOptions").show(); } if (settings.clientNotify === "true") { $("#clientNotify").prop("checked", true); $("#clientOptions").show(); } for (var i = 0; i < settings.allItems.length; i++) { var option = $("<option>").attr("value", settings.allItems[i]["id"]).text(settings.allItems[i]["title"]); $("#no_wa").append(option); } $("#no_wa").val(settings.no_wa); changeLabel(); } function saveSettingToServer() { this.disabled = true; $(".status").remove(); var integrasi = $("#integrasi").val(), key = $("#key").val(), no_wa = $("#no_wa").val(), template = $("#template").val(), adminNotify = $("#adminNotify").is(":checked") ? "true" : "false", clientNotify = $("#clientNotify").is(":checked") ? "true" : "false", noWaAdmin = $("#noWaAdmin").val(), templateAdmin = $("#templateAdmin").val(), settings = { integrasi: integrasi, key: key, no_wa: no_wa, template: template, adminNotify: adminNotify, clientNotify: clientNotify, noWaAdmin: noWaAdmin, templateAdmin: templateAdmin }; if (key == "" || integrasi == "") { showStatus("Please input valid data", $("#button-bar")); return; } google.script.run .withSuccessHandler(function (msg, element) { showStatus("Saved settings", $("#button-bar"), "success"); showStatus("Saved settings", $("#admin-button-bar"), "success"); showStatus("Saved settings", $("#client-button-bar"), "success"); element.disabled = false; }) .withFailureHandler(function (msg, element) { showStatus(msg, $("#button-bar"), "error"); showStatus(msg, $("#admin-button-bar"), "error"); showStatus(msg, $("#client-button-bar"), "error"); element.disabled = false; }) .withUserObject(this) .saveSettings(settings); } function showStatus(msg, element, cls = "error") { var div = $("<div>") .attr("class", "status " + cls) .text(msg); $(element).after(div); } function removeStatus() { $("#save").removeAttr("disabled"); $("#adminSave").removeAttr("disabled"); $("#clientSave").removeAttr("disabled"); $(".status").remove(); } function changeLabel() { $("label[for=key]").html('Device Key <span style="color: red;">*</span>'); console.log($("#integrasi").val()); var labelArr = { click2wasapmultics: "Device Key" }; var label = $("#integrasi").val() == "" ? "Device Key" : labelArr[$("#integrasi").val()]; $("label[for=key]").html(label + ' <span style="color: red;">*</span>'); } function toggleadminNotify() { $(".status").remove(); if ($("#adminNotify").is(":checked")) { $("#adminOptions").show(); } else { $("#adminOptions").hide(); } } function toggleclientNotify() { $(".status").remove(); if ($("#clientNotify").is(":checked")) { $("#clientOptions").show(); } else { $("#clientOptions").hide(); } } function setTrigger() { this.disabled = true; $("#status").remove(); google.script.run .withSuccessHandler(function (msg, element) { showStatus("Saved settings", $("#button-bar"), "success"); element.disabled = false; }) .withFailureHandler(function (msg, element) { showStatus(msg, $("#button-bar"), "error"); element.disabled = false; }) .withUserObject(this) .setTrigger(); } </script> ` ) .evaluate() .setTitle("Click2Wasap Settings"); FormApp.getUi().showSidebar(ui); } function showAbout() { var ui = HtmlService.createHtmlOutput("Add-ons Integrations "+ ADDON_TITLE +" with Google Forms!").setWidth(420).setHeight(270); FormApp.getUi().showModalDialog(ui, "About Click2Wasap"); } function saveSettings(settings) { PropertiesService.getDocumentProperties().setProperties(settings); } function getSettings() { var settings = PropertiesService.getDocumentProperties().getProperties(); if (!settings.creatorEmail) { settings.creatorEmail = Session.getEffectiveUser().getEmail(); } var form = FormApp.getActiveForm(); var TEXT = form.getItems(FormApp.ItemType.TEXT); var PARAGRAPH_TEXT = form.getItems(FormApp.ItemType.PARAGRAPH_TEXT); var CHECKBOX = form.getItems(FormApp.ItemType.CHECKBOX); var MULTIPLE_CHOICE = form.getItems(FormApp.ItemType.MULTIPLE_CHOICE); var LIST = form.getItems(FormApp.ItemType.LIST); var SCALE = form.getItems(FormApp.ItemType.SCALE); var GRID = form.getItems(FormApp.ItemType.GRID); var CHECKBOX_GRID = form.getItems(FormApp.ItemType.CHECKBOX_GRID); var allItems = TEXT.concat(PARAGRAPH_TEXT, CHECKBOX, CHECKBOX_GRID, GRID, MULTIPLE_CHOICE, LIST, SCALE); Logger.log(allItems); settings.allItems = []; for (var i = 0; i < allItems.length; i++) { settings.allItems.push({ title: allItems[i].getTitle(), id: allItems[i].getId() }); } return settings; } function adjustFormSubmitTrigger() { var form = FormApp.getActiveForm(); var triggers = ScriptApp.getUserTriggers(form); var triggerNeeded = "true"; var existingTrigger = null; for (var i = 0; i < triggers.length; i++) { if (triggers[i].getEventType() == ScriptApp.EventType.ON_FORM_SUBMIT) { existingTrigger = triggers[i]; break; } } if (triggerNeeded && !existingTrigger) { var trigger = ScriptApp.newTrigger("respondToFormSubmit").forForm(form).onFormSubmit().create(); } else if (!triggerNeeded && existingTrigger) { ScriptApp.deleteTrigger(existingTrigger); } } function respondToFormSubmit(e) { var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL); if (authInfo.getAuthorizationStatus() == ScriptApp.AuthorizationStatus.REQUIRED) { sendReauthorizationRequest(); } else { sendRespondentNotification(e); } } function sendReauthorizationRequest() { var settings = PropertiesService.getDocumentProperties(); var authInfo = ScriptApp.getAuthorizationInfo(ScriptApp.AuthMode.FULL); var lastAuthEmailDate = settings.getProperty("lastAuthEmailDate"); var today = new Date().toDateString(); if (lastAuthEmailDate != today) { if (MailApp.getRemainingDailyQuota() > 0) { var template = HtmlService.createTemplate( `<p>The Google Form add-on <i>`+ ADDON_TITLE +`</i> is set to run automatically whenever a form is submitted. The add-on was recently updated and it needs you to re-authorize it to run on your behalf.</p> <p>The add-on's automatic functions are temporarily disabled until you re-authorize it. To do so, open Google Form and run the add-on from the Add-ons menu. Alternatively, you can click this link to authorize it:</p> <p><a href="<?= url ?>">Re-authorize the add-on.</a></p> <p>This notification email will be sent to you at most once per day until the add-on is re-authorized.</p>` ); template.url = authInfo.getAuthorizationUrl(); template.notice = NOTICE; var message = template.evaluate(); MailApp.sendEmail(Session.getEffectiveUser().getEmail(), "Authorization Required", message.getContent(), { name: ADDON_TITLE, htmlBody: message.getContent() }); } settings.setProperty("lastAuthEmailDate", today); } } function sendToAdmin(msgAdmin) { var settings = PropertiesService.getDocumentProperties(); var adminNotifyProperty = settings.getProperty("adminNotify"); if (adminNotifyProperty === "true") { var noWaAdminProperty = settings.getProperty("noWaAdmin"); var arrNowa = noWaAdminProperty.split(","); arrNowa.forEach(function (noWaAdmin, index) { var setting = getSettings(); noWaAdmin = validatePhone(noWaAdmin); switch (setting.integrasi) { case "click2wasapmultics": multicsSendWa(noWaAdmin, msgAdmin, setting.key); break; default: Logger.log("Error: integrasi value is " + setting.integrasi); break; } Utilities.sleep(7 * 1000); }); } else { Logger.log("false"); } return; } function sendRespondentNotification(e) { var response = e.response; var form = FormApp.getActiveForm(); var settings = PropertiesService.getDocumentProperties(); var no_wa_property = settings.getProperty("no_wa"); var no_wa_item = form.getItemById(parseInt(no_wa_property)); var no_wa = response.getResponseForItem(no_wa_item).getResponse(); no_wa = validatePhone(no_wa); if (no_wa == "") { Logger.log("No Wa is empty"); return; } var template = settings.getProperty("template"), templateAdmin = settings.getProperty("templateAdmin"), matches = [], find = [], replace = [], curMatch, no_wa, rxp = /\[([^\]]+)\]/g; while ((curMatch = rxp.exec(template))) { matches.push(curMatch[1]); } while ((curMatch = rxp.exec(templateAdmin))) { if(matches.find(e => e == curMatch[1])) { continue } matches.push(curMatch[1]); } var setting = getSettings(); if (setting.integrasi) { if (matches) { matches.forEach(function (item, index) { var formData = objectifyForm(); if (formData[item]) { find.push("[" + item + "]"); replace.push(formData[item]); } var timestamp = new Date().toISOString().split("T").join(" ").slice(0, 10); var date = new Date().toISOString().split("T").join(" ").slice(0, 19); if (item == "Timestamp") { find.push("[Timestamp]"); replace.push(timestamp); } if (item == "timestamp") { find.push("[timestamp]"); replace.push(timestamp); } if (item == "Date") { find.push("[Date]"); replace.push(date); } if (item == "date") { find.push("[date]"); replace.push(date); } }); var msg = template.replaceArray(find, replace); var msgAdmin = templateAdmin.replaceArray(find, replace); } var clientNotifyProperty = settings.getProperty("clientNotify"); if (clientNotifyProperty === "true") { switch (setting.integrasi) { case "click2wasapmultics": multicsSendWa(no_wa, msg, setting.key); break; default: Logger.log("Error: integrasi value is " + setting.integrasi); break; } Utilities.sleep(7 * 1000); } sendToAdmin(msgAdmin); return; } } String.prototype.replaceArray = function (find, replace) { var replaceString = this; for (var i = 0; i < find.length; i++) { replaceString = replaceString.replace(find[i], replace[i]); } return replaceString; }; function objectifyForm() { var myform = FormApp.getActiveForm(); var formResponses = myform.getResponses(); var currentResponse = formResponses[formResponses.length - 1]; var responseArray = currentResponse.getItemResponses(); var form = {}; form.user = currentResponse.getRespondentEmail(); form.timestamp = currentResponse.getTimestamp(); form.formName = myform.getTitle(); for (var i = 0; i < responseArray.length; i++) { var response = responseArray[i].getResponse(); var item = responseArray[i].getItem().getTitle(); form[item] = response; } return form; } function validatePhone(no_wa) { if (typeof no_wa == "string") { var no_wa = no_wa.split(/[^0-9]/).join(""); no_wa = no_wa.replace(/^[0]/, "60"); } else { no_wa = ""; } return no_wa; } function spinText(msg) { if (msg.indexOf("{") == 0) { var get_spintext = msg.substring(0, msg.indexOf("}")); var explode_kurawal_buka = msg.split("{"); var explode_kurawal_tutup = explode_kurawal_buka[1].split("}"); var explode = explode_kurawal_tutup[0].split("|"); var spintext = explode[Math.floor(Math.random() * explode.length)]; msg = msg.replace(get_spintext, spintext); msg = msg.replace("}", "", spintext); msg = msg.replace("|", "", spintext); } if (msg.indexOf("{") > 0) { var get_spintext = msg.substring(0, msg.indexOf("}")); var get_spintext1 = get_spintext.substring(msg.indexOf("{")); var explode_kurawal_buka = msg.split("{"); var explode = explode_kurawal_buka[1].split("|"); var spintext = explode[Math.floor(Math.random() * explode.length)]; msg = msg.replace(get_spintext1, spintext); msg = msg.replace("}", "", spintext); msg = msg.replace("|", "", spintext); } return msg; } function multicsSendWa(no_wa, msg, deviceKey) { var msg = spinText(msg); var url = "https://node.click2wasap.com/api/srv1/send-text"; var data = { number: no_wa, message: msg }; var headers = { "Content-Type": "application/x-www-form-urlencoded", "device-key": deviceKey, "Cache-Control": "no-cache" }; var options = { method: "post", payload: data, headers: headers, muteHttpExceptions: !![] }; var response = UrlFetchApp.fetch(url, options); var result = response.getContentText(); Logger.log(result); return; } 


  

This script is used to make Click2Wasap Add-on!

Tutorial Links
Google Docs

Contact Us



























php
t