Skip to content

Commit eb49b08

Browse files
authored
Merge pull request #105 from Vonage/messages-v1-whatsapp-messenger-updates
Messages v1 whatsapp messenger updates
2 parents 281dd23 + 6a46b85 commit eb49b08

17 files changed

+390
-495
lines changed

messages/messenger/send-audio.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@ curl -X POST $MESSAGES_API_URL \
77
-H 'Authorization: Bearer '$JWT \
88
-H 'Content-Type: application/json' \
99
-d $'{
10-
"to": {
11-
"type": "messenger",
12-
"id": "'$FB_RECIPIENT_ID'"
10+
"message_type": "audio",
11+
"audio": {
12+
"url": "'$AUDIO_URL'"
1313
},
14-
"message": {
15-
"content": {
16-
"type": "audio",
17-
"audio": {
18-
"url": "'$AUDIO_URL'"
19-
}
20-
}
21-
},
22-
"from": {
23-
"type": "messenger",
24-
"id": "'$FB_SENDER_ID'"
25-
}
14+
"to": "'$FB_RECIPIENT_ID'",
15+
"from": "'$FB_SENDER_ID'",
16+
"channel": "messenger"
2617
}'

messages/messenger/send-file.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@ curl -X POST $MESSAGES_API_URL \
77
-H 'Authorization: Bearer '$JWT \
88
-H 'Content-Type: application/json' \
99
-d $'{
10-
"to": {
11-
"type": "messenger",
12-
"id": "'$FB_RECIPIENT_ID'"
10+
"message_type": "file",
11+
"file": {
12+
"url": "'$FILE_URL'"
1313
},
14-
"message": {
15-
"content": {
16-
"type": "file",
17-
"file": {
18-
"url": "'$FILE_URL'"
19-
}
20-
}
21-
},
22-
"from": {
23-
"type": "messenger",
24-
"id": "'$FB_SENDER_ID'"
25-
}
14+
"to": "'$FB_RECIPIENT_ID'",
15+
"from": "'$FB_SENDER_ID'",
16+
"channel": "messenger"
2617
}'

messages/messenger/send-image.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@ curl -X POST $MESSAGES_API_URL \
77
-H 'Authorization: Bearer '$JWT \
88
-H 'Content-Type: application/json' \
99
-d $'{
10-
"to": {
11-
"type": "messenger",
12-
"id": "'$FB_RECIPIENT_ID'"
10+
"message_type": "image",
11+
"image": {
12+
"url": "'$IMAGE_URL'"
1313
},
14-
"message": {
15-
"content": {
16-
"type": "image",
17-
"image": {
18-
"url": "'$IMAGE_URL'"
19-
}
20-
}
21-
},
22-
"from": {
23-
"type": "messenger",
24-
"id": "'$FB_SENDER_ID'"
25-
}
14+
"to": "'$FB_RECIPIENT_ID'",
15+
"from": "'$FB_SENDER_ID'",
16+
"channel": "messenger"
2617
}'

messages/messenger/send-template.sh

Lines changed: 64 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -7,82 +7,73 @@ curl -X POST $MESSAGES_API_URL \
77
-H 'Authorization: Bearer '$JWT \
88
-H 'Content-Type: application/json' \
99
-d $'{
10-
"from": {
11-
"type": "messenger",
12-
"id": "'$FB_SENDER_ID'"
13-
},
14-
"to": {
15-
"type": "messenger",
16-
"id": "'$FB_RECIPIENT_ID'"
17-
},
18-
"message": {
19-
"content": {
20-
"type": "custom",
21-
"custom": {
22-
"attachment": {
23-
"type": "template",
24-
"payload": {
25-
"template_type": "airline_boardingpass",
26-
"intro_message": "You are checked in.",
27-
"locale": "en_US",
28-
"boarding_pass": [
10+
"to": "'$FB_RECIPIENT_ID'",
11+
"from": "'$FB_SENDER_ID'",
12+
"channel": "messenger",
13+
"message_type": "custom",
14+
"custom": {
15+
"attachment": {
16+
"type": "template",
17+
"payload": {
18+
"template_type": "airline_boardingpass",
19+
"intro_message": "You are checked in.",
20+
"locale": "en_US",
21+
"boarding_pass": [
22+
{
23+
"passenger_name": "OTHER/A",
24+
"pnr_number": "CG4X7U",
25+
"seat": "1A",
26+
"logo_image_url": "'$LOGO_IMAGE_URL'",
27+
"header_image_url": "'$HEADER_IMAGE_URL'",
28+
"qr_code": "M1OTHER/A CG4X7U nawouehgawgnapwi3jfa0wfh",
29+
"above_bar_code_image_url": "'$ABOVE_BAR_CODE_IMAGE_URL'",
30+
"auxiliary_fields": [
2931
{
30-
"passenger_name": "OTHER/A",
31-
"pnr_number": "CG4X7U",
32-
"seat": "1A",
33-
"logo_image_url": "'$LOGO_IMAGE_URL'",
34-
"header_image_url": "'$HEADER_IMAGE_URL'",
35-
"qr_code": "M1OTHER/A CG4X7U nawouehgawgnapwi3jfa0wfh",
36-
"above_bar_code_image_url": "'$ABOVE_BAR_CODE_IMAGE_URL'",
37-
"auxiliary_fields": [
38-
{
39-
"label": "Terminal",
40-
"value": "T1"
41-
},
42-
{
43-
"label": "Departure",
44-
"value": "30OCT 19:05"
45-
}
46-
],
47-
"secondary_fields": [
48-
{
49-
"label": "Boarding",
50-
"value": "18:30"
51-
},
52-
{
53-
"label": "Gate",
54-
"value": "D57"
55-
},
56-
{
57-
"label": "Seat",
58-
"value": "74J"
59-
},
60-
{
61-
"label": "Sec.Nr.",
62-
"value": "003"
63-
}
64-
],
65-
"flight_info": {
66-
"flight_number": "KL0642",
67-
"departure_airport": {
68-
"airport_code": "SFO",
69-
"city": "San Francisco",
70-
"terminal": "T1",
71-
"gate": "D57"
72-
},
73-
"arrival_airport": {
74-
"airport_code": "LHR",
75-
"city": "London"
76-
},
77-
"flight_schedule": {
78-
"departure_time": "2018-03-02T19:05",
79-
"arrival_time": "2018-03-05T17:30"
80-
}
81-
}
32+
"label": "Terminal",
33+
"value": "T1"
34+
},
35+
{
36+
"label": "Departure",
37+
"value": "30OCT 19:05"
38+
}
39+
],
40+
"secondary_fields": [
41+
{
42+
"label": "Boarding",
43+
"value": "18:30"
44+
},
45+
{
46+
"label": "Gate",
47+
"value": "D57"
48+
},
49+
{
50+
"label": "Seat",
51+
"value": "74J"
52+
},
53+
{
54+
"label": "Sec.Nr.",
55+
"value": "003"
56+
}
57+
],
58+
"flight_info": {
59+
"flight_number": "KL0642",
60+
"departure_airport": {
61+
"airport_code": "SFO",
62+
"city": "San Francisco",
63+
"terminal": "T1",
64+
"gate": "D57"
65+
},
66+
"arrival_airport": {
67+
"airport_code": "LHR",
68+
"city": "London"
69+
},
70+
"flight_schedule": {
71+
"departure_time": "2018-03-02T19:05",
72+
"arrival_time": "2018-03-05T17:30"
8273
}
83-
]
74+
}
8475
}
85-
}
76+
]
8677
}
8778
}
8879
}

messages/messenger/send-text.sh

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

66
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-
"from": { "type": "messenger", "id": "'$FB_SENDER_ID'" },
12-
"to": { "type": "messenger", "id": "'$FB_RECIPIENT_ID'" },
13-
"message": {
14-
"content": {
15-
"type": "text",
16-
"text": "This is a Facebook Messenger Message sent from the Messages API"
17-
}
18-
}
19-
}'
7+
-H 'Authorization: Bearer '$JWT\
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"message_type": "text",
12+
"text": "This is a Facebook Messenger Message sent from the Messages API",
13+
"to": "'$FB_RECIPIENT_ID'",
14+
"from": "'$FB_SENDER_ID'",
15+
"channel": "messenger"
16+
}'

messages/messenger/send-video.sh

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,11 @@ curl -X POST $MESSAGES_API_URL \
77
-H 'Authorization: Bearer '$JWT \
88
-H 'Content-Type: application/json' \
99
-d $'{
10-
"to": {
11-
"type": "messenger",
12-
"id": "'$FB_RECIPIENT_ID'"
10+
"message_type": "video",
11+
"video": {
12+
"url": "'$VIDEO_URL'"
1313
},
14-
"message": {
15-
"content": {
16-
"type": "video",
17-
"video": {
18-
"url": "'$VIDEO_URL'"
19-
}
20-
}
21-
},
22-
"from": {
23-
"type": "messenger",
24-
"id": "'$FB_SENDER_ID'"
25-
}
14+
"to": "'$FB_RECIPIENT_ID'",
15+
"from": "'$FB_SENDER_ID'",
16+
"channel": "messenger"
2617
}'

messages/whatsapp/send-audio.sh

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@ source "../../config.sh"
44
source "../../jwt.sh"
55

66
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-
"from": { "type": "whatsapp", "number": "'$WHATSAPP_NUMBER'" },
12-
"to": { "type": "whatsapp", "number": "'$TO_NUMBER'" },
13-
"message": {
14-
"content": {
15-
"type": "audio",
16-
"audio": {
17-
"url": "'$AUDIO_URL'",
18-
}
19-
}
20-
}
21-
}'
7+
-H 'Authorization: Bearer '$JWT \
8+
-H 'Content-Type: application/json' \
9+
-H 'Accept: application/json' \
10+
-d $'{
11+
"message_type": "audio",
12+
"audio": {
13+
"url": "'$AUDIO_URL'"
14+
},
15+
"to": "'$TO_NUMBER'",
16+
"from": "'$WHATSAPP_NUMBER'",
17+
"channel": "whatsapp"
18+
}'

0 commit comments

Comments
 (0)