Skip to content

Commit 7cf8571

Browse files
committed
Updating WhatsApp snippets
1 parent ba0ca03 commit 7cf8571

12 files changed

+371
-302
lines changed

config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ VIBER_SERVICE_MESSAGE_ID=${VIBER_SERVICE_MESSAGE_ID:-""}
2828
# For WhatsApp messaging
2929
WHATSAPP_NUMBER=${WHATSAPP_NUMBER:-""}
3030
WHATSAPP_TEMPLATE_NAMESPACE=${WHATSAPP_TEMPLATE_NAMESPACE:-"whatsapp:hsm:technology:nexmo"}
31-
WHATSAPP_TEMPLATE_NAME=${WHATSAPP_TEMPLATE_NAME:-"verify"}
31+
WHATSAPP_TEMPLATE_NAME=${WHATSAPP_TEMPLATE_NAME:-""}
3232
WHATSAPP_AUTH_TEMPLATE_NAME=${WHATSAPP_AUTH_TEMPLATE_NAME:-""}
3333
WHATSAPP_TEMPLATE_REPLACEMENT_TEXT=${WHATSAPP_TEMPLATE_REPLACEMENT_TEXT:-""}
3434

messages/mms/send-mms-audio.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
source "../../config.sh"
4+
source "../../jwt.sh"
5+
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${MMS_SENDER_ID}'",
13+
"channel": "mms",
14+
"message_type": "audio",
15+
"audio": {
16+
"url": "'${MESSAGES_AUDIO_URL}'"
17+
}
18+
}'

messages/mms/send-mms-vcard.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
source "../../config.sh"
4+
source "../../jwt.sh"
5+
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${MMS_SENDER_ID}'",
13+
"channel": "mms",
14+
"message_type": "vcard",
15+
"vcard": {
16+
"url": "'${MESSAGES_VCARD_URL}'"
17+
}
18+
}'

messages/mms/send-mms-video.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
source "../../config.sh"
4+
source "../../jwt.sh"
5+
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${MMS_SENDER_ID}'",
13+
"channel": "mms",
14+
"message_type": "video",
15+
"video": {
16+
"url": "'${MESSAGES_VIDEO_URL}'"
17+
}
18+
}'

messages/mms/send-mms.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
source "../../config.sh"
44
source "../../jwt.sh"
55

6-
curl -X POST https://api.nexmo.com/v1/messages \
7-
-H 'Authorization: Bearer '$JWT\
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
88
-H 'Content-Type: application/json' \
99
-H 'Accept: application/json' \
1010
-d $'{
11-
"message_type": "image",
12-
"image": {
13-
"url": "https://example.com/image.jpg"
14-
},
15-
"to": "'$TO_NUMBER'",
16-
"from": "'$FROM_NUMBER'",
17-
"channel": "mms"
18-
}'
19-
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${MMS_SENDER_ID}'",
13+
"channel": "mms",
14+
"message_type": "image",
15+
"image": {
16+
"url": "'${MESSAGES_IMAGE_URL}'"
17+
}
18+
}'

messages/whatsapp/send-authentication-template.sh

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,45 @@
33
source "../../config.sh"
44
source "../../jwt.sh"
55

6-
curl -X POST $MESSAGES_API_URL \
7-
-H 'Authorization: Bearer' $JWT \
8-
-H 'Content-Type: application/json' \
9-
-d '{
10-
"to": "'$TO_NUMBER'",
11-
"from": "'$WHATSAPP_NUMBER'",
12-
"channel": "whatsapp",
13-
"message_type": "custom",
14-
"custom": {
15-
"type": "template",
16-
"template": {
17-
"name": "'$WHATSAPP_AUTH_TEMPLATE_NAME'",
18-
"language": {
19-
"policy": "deterministic",
20-
"code": "en"
21-
},
22-
"components": [
23-
{
24-
"type": "body",
25-
"parameters": [
26-
{
27-
"type": "text",
28-
"text": "'$OTP'"
29-
}
30-
]
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${WHATSAPP_SENDER_ID}'",
13+
"channel": "whatsapp",
14+
"message_type": "custom",
15+
"custom": {
16+
"type": "template",
17+
"template": {
18+
"name": "'${WHATSAPP_TEMPLATE_NAME}'",
19+
"language": {
20+
"policy": "deterministic",
21+
"code": "en"
3122
},
32-
{
33-
"type": "button",
34-
"sub_type": "url",
35-
"index": "0",
36-
"parameters": [
37-
{
38-
"type": "text",
39-
"text": "'$OTP'"
40-
}
41-
]
42-
}
43-
]
23+
"components": [
24+
{
25+
"type": "body",
26+
"parameters": [
27+
{
28+
"type": "text",
29+
"text": "'${WHATSAPP_OTP}'"
30+
}
31+
]
32+
},
33+
{
34+
"type": "button",
35+
"sub_type": "url",
36+
"index": "0",
37+
"parameters": [
38+
{
39+
"type": "text",
40+
"text": "'${WHATSAPP_OTP}'"
41+
}
42+
]
43+
}
44+
]
45+
}
4446
}
45-
}
46-
}'
47+
}'

messages/whatsapp/send-button-link.sh

Lines changed: 55 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -3,68 +3,60 @@
33
source "../../config.sh"
44
source "../../jwt.sh"
55

6-
curl -X POST $MESSAGES_API_URL \
7-
-H 'Authorization: Bearer' $JWT \
8-
-H 'Content-Type: application/json' \
9-
-d '{
10-
"message_type": "custom",
11-
"to": "'$TO_NUMBER'",
12-
"from": "'$WHATSAPP_NUMBER'",
13-
"channel": "whatsapp",
14-
"custom": {
15-
"type": "template",
16-
"template": {
17-
"namespace": "'$WHATSAPP_TEMPLATE_NAMESPACE'",
18-
"name": "'$WHATSAPP_TEMPLATE_NAME'",
19-
"language": {
20-
"code": "en",
21-
"policy": "deterministic"
22-
},
23-
"components": [
24-
{
25-
"type": "header",
26-
"parameters": [
27-
{
28-
"type": "image",
29-
"image": {
30-
"link": "'$HEADER_IMAGE_URL'"
31-
}
32-
}
33-
]
34-
},
35-
{
36-
"type": "body",
37-
"parameters": [
38-
{
39-
"type": "text",
40-
"text": "Anand"
41-
},
42-
{
43-
"type": "text",
44-
"text": "Quest"
45-
},
46-
{
47-
"type": "text",
48-
"text": "113-0921387"
49-
},
50-
{
51-
"type": "text",
52-
"text": "23rd Nov 2019"
53-
}
54-
]
6+
curl -X POST "${MESSAGES_API_URL}" \
7+
-H "Authorization: Bearer ${JWT}"\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"to": "'${MESSAGES_TO_NUMBER}'",
12+
"from": "'${WHATSAPP_SENDER_ID}'",
13+
"channel": "whatsapp",
14+
"message_type": "custom",
15+
"custom": {
16+
"type": "template",
17+
"template": {
18+
"name": "'${WHATSAPP_TEMPLATE_NAME}'",
19+
"language": {
20+
"policy": "deterministic",
21+
"code": "en"
5522
},
56-
{
57-
"type": "button",
58-
"index": "0",
59-
"sub_type": "url",
60-
"parameters": [
61-
{
62-
"type": "text",
63-
"text": "1Z999AA10123456784"
64-
}
65-
]
66-
}
67-
]
23+
"components": [
24+
{
25+
"type": "header",
26+
"parameters": [
27+
{
28+
"type": "image",
29+
"image": {
30+
"link": "'${MESSAGES_IMAGE_URL}'"
31+
}
32+
}
33+
]
34+
},
35+
{
36+
"type": "body",
37+
"parameters": [
38+
{
39+
"type": "text",
40+
"text": "Joe Bloggs"
41+
},
42+
{
43+
"type": "text",
44+
"text": "AB123456"
45+
}
46+
]
47+
},
48+
{
49+
"type": "button",
50+
"index": "0",
51+
"sub_type": "url",
52+
"parameters": [
53+
{
54+
"type": "text",
55+
"text": "AB123456"
56+
}
57+
]
58+
}
59+
]
60+
}
6861
}
69-
}
70-
}'
62+
}'

0 commit comments

Comments
 (0)