-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Messages Sandbox WhatsApp snippet (#104)
* Adding Messages Sandbox examples
- Loading branch information
1 parent
1e85f18
commit 977d149
Showing
4 changed files
with
89 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'dotenv/load' | ||
require 'vonage' | ||
|
||
VONAGE_APPLICATION_ID = ENV['VONAGE_APPLICATION_ID'] | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = ENV['VONAGE_APPLICATION_PRIVATE_KEY_PATH'] | ||
MESSAGES_SANDBOX_URL= ENV['MESSAGES_SANDBOX_URL'] | ||
MESSAGES_SANDBOX_FB_ID = ENV['MESSAGES_SANDBOX_FB_ID'] | ||
MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID = ENV['MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID'] | ||
|
||
client = Vonage::Client.new( | ||
application_id: VONAGE_APPLICATION_ID, | ||
private_key: File.read(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
api_host: MESSAGES_SANDBOX_URL | ||
) | ||
|
||
message = Vonage::Messaging::Message.messenger( | ||
type: 'text', | ||
message: "This is a Facebook Messenger text message sent using the Messages API via the Messages Sandbox" | ||
) | ||
|
||
client.messaging.send( | ||
from: MESSAGES_SANDBOX_FB_ID, | ||
to: MESSAGES_SANDBOX_ALLOW_LISTED_FB_RECIPIENT_ID, | ||
**message | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'dotenv/load' | ||
require 'vonage' | ||
|
||
VONAGE_APPLICATION_ID = ENV['VONAGE_APPLICATION_ID'] | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = ENV['VONAGE_APPLICATION_PRIVATE_KEY_PATH'] | ||
MESSAGES_SANDBOX_URL= ENV['MESSAGES_SANDBOX_URL'] | ||
MESSAGES_SANDBOX_VIBER_SERVICE_ID = ENV['MESSAGES_SANDBOX_VIBER_SERVICE_ID'] | ||
MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER = ENV['MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER'] | ||
|
||
client = Vonage::Client.new( | ||
application_id: VONAGE_APPLICATION_ID, | ||
private_key: File.read(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
api_host: MESSAGES_SANDBOX_URL | ||
) | ||
|
||
message = Vonage::Messaging::Message.viber( | ||
type: 'text', | ||
message: "This is a Viber Service Message text message sent using the Messages API via the Messages Sandbox" | ||
) | ||
|
||
client.messaging.send( | ||
from: MESSAGES_SANDBOX_VIBER_SERVICE_ID, | ||
to: MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER, | ||
**message | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require 'dotenv/load' | ||
require 'vonage' | ||
|
||
VONAGE_APPLICATION_ID = ENV['VONAGE_APPLICATION_ID'] | ||
VONAGE_APPLICATION_PRIVATE_KEY_PATH = ENV['VONAGE_APPLICATION_PRIVATE_KEY_PATH'] | ||
MESSAGES_SANDBOX_URL= ENV['MESSAGES_SANDBOX_URL'] | ||
MESSAGES_SANDBOX_WHATSAPP_NUMBER = ENV['MESSAGES_SANDBOX_WHATSAPP_NUMBER'] | ||
MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER = ENV['MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER'] | ||
|
||
client = Vonage::Client.new( | ||
application_id: VONAGE_APPLICATION_ID, | ||
private_key: File.read(VONAGE_APPLICATION_PRIVATE_KEY_PATH), | ||
api_host: MESSAGES_SANDBOX_URL | ||
) | ||
|
||
message = Vonage::Messaging::Message.whatsapp( | ||
type: 'text', | ||
message: "This is a WhatsApp Message text message sent using the Messages API via the Messages Sandbox" | ||
) | ||
|
||
client.messaging.send( | ||
from: MESSAGES_SANDBOX_WHATSAPP_NUMBER, | ||
to: MESSAGES_SANDBOX_ALLOW_LISTED_TO_NUMBER, | ||
**message | ||
) |