メッセージ用 API の概要
メッセージ用 API は次の通信チャネルでのメッセージ送信 (一部は送受信) に対応しています。
- SMS/MMS
- Facebook Messenger
- Viber
今後、他のチャネルもサポートする可能性があります。
下図ではメッセージ用 API と配信用 API の関係が示されています。

内容
ベータ版について
この API は現在ベータ版です。
Nexmo ではユーザーからのフィードバックを常に歓迎しています。ご提案は製品の改善に役立ちます。サポートが必要な場合は件名に「メッセージ用 API」を含めて、api.support@api.vonage.com 宛てにメールを送信してください。恐れ入りますが、ベータ版の期間中、サポート対応時間は月曜から金曜に限定させていただきます。
Nexmo はベータ版の期間中、API 機能の拡張に取り組みます。
サポート機能
今回のリリースでは次の機能をサポートしています。
| チャネル | 発信テキスト | 発信画像 | 発信オーディオ | 発信動画 | 発信ファイル | 発信テンプレート |
|---|---|---|---|---|---|---|
| SMS | 非対応 | 非対応 | 非対応 | 非対応 | 非対応 | |
| MMS | 非対応 | 非対応 | 非対応 | 非対応 | ||
| Viber サービスメッセージ | 非対応 | 非対応 | 非対応 | |||
| Facebook Messenger | ||||||
| チャネル | 着信テキスト | 着信画像 | 着信オーディオ | 着信動画 | 着信ファイル | 着信場所 |
|---|---|---|---|---|---|---|
| MMS | 非対応 | 非対応 | 非対応 | 非対応 | ||
| Viber サービスメッセージ | 非対応 | 非対応 | 非対応 | 非対応 | 非対応 | |
| Facebook Messenger | ||||||
下表のとおり、カスタムオブジェクトも一部サポートしています。
| チャネル | 発信ボタン | 発信場所 | 発信連絡先 |
|---|---|---|---|
| SMS | 非対応 | 非対応 | 非対応 |
| MMS | 非対応 | 非対応 | 非対応 |
| Viber サービスメッセージ | 非対応 | 非対応 | |
| Facebook Messenger | 非対応 | 非対応 | |
キー:
= サポート対象。 = チャネルではサポート対象、Nexmo ではサポート対象外。 - n/a = 該当チャネルではサポート対象外。
外部アカウント用 API
外部アカウント用 API は Viber サービスメッセージ、Facebook Messenger、WhatsApp をメッセージ用 API と配信用 API で使用する際、各チャネルのアカウント管理に使用されます。
最初のステップ
この例では、適当な手段を使って次の変数を実際の値に置き換える必要があります。
| キー | 説明 |
|---|---|
NEXMO_API_KEY | Nexmo API のキー (Nexmo Dashboard から取得可能)。 |
NEXMO_API_SECRET | Nexmo API のシークレット (Nexmo Dashboard から取得可能)。 |
FROM_NUMBER | 自分の電話番号または送信者の識別用テキスト。 |
TO_NUMBER | メッセージの送信先となる電話番号。 |
注: 電話番号は先頭に + や 00 を付けずに国番号から入力してください (例: 447700900000)。
次のコードはメッセージ用 API を使った SMS メッセージの送信方法を示しています。
Write the code
Add the following to send-sms-basic-auth.sh:
-u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"to": "'${MESSAGES_TO_NUMBER}'",
"from": "'${SMS_SENDER_ID}'",
"channel": "sms",
"message_type": "text",
"text": "This is an SMS sent using the Vonage Messages API."
}'
Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdk @vonage/messagesCreate a file named send-sms-basic-auth.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
const { Channels } = require('@vonage/messages');
/**
* By leaving out the applicationId and privateKey parameters, the Vonage
* SDK will use basic authentication to authenticate with the Messages API.
*
* @link https://developer.vonage.com/en/messages/technical-details#authentication
*/
const vonage = new Vonage(
{
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
},
{
...(MESSAGES_API_URL ? {apiHost: MESSAGES_API_URL} : {}),
},
);Write the code
Add the following to send-sms-basic-auth.js:
vonage.messages.send({
messageType: 'sms',
channel: Channels.SMS,
text: 'This is an SMS text message sent using the Messages API',
to: MESSAGES_TO_NUMBER,
from: SMS_SENDER_ID,
})
.then(({ messageUUID }) => console.log(messageUUID))
.catch((error) => console.error(error));Run your code
Save this file to your machine and run it:
基本概念
- WhatsApp Interactive Messages: Brief overview of WhatsApp interactive messages.
- WhatsApp v0.1 to v1 Migration Guide: Differences to be aware of between the two versions of the API if migrating to v1
- Messages API Guides: Learn more about working with the Messages API.
- Messages API Concepts: Discover more about the Messages API with these pages explaining key concepts and terminology.
- Working with WhatsApp Interactive Messages: General workflow for working with WhatsApp interactive messages, and examples of lists and reply buttons
- Understanding SMS messaging: SMS messages with the Vonage Messages API.
- WhatsApp Product Messages: An overview of WhatsApp product messages.
- Sending a Message with Failover: Message Failover automatically redirects your message to the next available communication channel if the first delivery method is rejected or fails.
- Understanding RCS messaging
- Using WhatsApp Stickers
- WhatsApp Outbound Reply Messages: An overview of WhatsApp Outbound Reply Messages
- Understanding WhatsApp messaging: WhatsApp messaging solution for businesses.
- WhatsApp Template Management API: The WhatsApp Template Management API allows you to list existing WhatsApp templates, create new templates, delete templates, and upload files for use in templates.
- Understanding Facebook messaging: Understanding Facebook messaging.
- Understanding Viber messaging: Viber messaging solution for businesses.
- External Accounts: External accounts are Messaging accounts such as Facebook, WhatsApp and Viber that you want to link to your Messages and Dispatch applications.
- Custom objects: Understanding custom objects
- Secure Inbound Media: When the Secure Inbound Media is enabled, you will need to use your Messages Application credentials (Authorisation Bearer JWT) to retrieve the media file for all channels.
- Messages API Sandbox: Understanding and utilizing the Messages API Sandbox.
- US Number Deactivation File: You can retrieve a list of US numbers that have been deactivated
コードスニペット
- Before you Begin
- Configure Webhooks
- Create a Vonage Messages Application
- Inbound Message Webhook
- Install Server SDK
- Message Status Webhook
- Messenger / Send a File Message
- Messenger / Send a Text Message
- Messenger / Send a Video Message
- Messenger / Send an Audio Message
- Messenger / Send an Image Message
- Mms / Send an MMS
- Rcs / Revoke an Outbound RCS Message
- Rcs / Send a RCS File Message
- Rcs / Send a RCS Image Message
- Rcs / Send a RCS Rich Card Carousel Message
- Rcs / Send a RCS Standalone Rich Card Message
- Rcs / Send a RCS Suggested Action (Create Calendar Event) Message
- Rcs / Send a RCS Suggested Action (Dial a Number) Message
- Rcs / Send a RCS Suggested Action (Multiple Actions) Message
- Rcs / Send a RCS Suggested Action (Open a URL in a Webview) Message
- Rcs / Send a RCS Suggested Action (Open a URL) Message
- Rcs / Send a RCS Suggested Action (Share a Location) Message
- Rcs / Send a RCS Suggested Action (View a Location) Message
- Rcs / Send a RCS Suggested Reply Message
- Rcs / Send a RCS Text Message
- Rcs / Send a RCS Video Message
- Send a Message with Failover
- Sms / Send an SMS
- Viber / Send a File
- Viber / Send a Text Message
- Viber / Send a Video
- Viber / Send an Image Message
- Whatsapp / Mark as Read
- Whatsapp / Send a Contact
- Whatsapp / Send a File Message
- Whatsapp / Send a Link Button
- Whatsapp / Send a Location
- Whatsapp / Send a Media Message Template
- Whatsapp / Send a Message Template (MTM)
- Whatsapp / Send a Multiple Item Product Message
- Whatsapp / Send a Quick Reply Button
- Whatsapp / Send a Reaction
- Whatsapp / Send a Single Item Product Message
- Whatsapp / Send a Text Message
- Whatsapp / Send a Video Message
- Whatsapp / Send an Audio Message
- Whatsapp / Send an Authentication Template
- Whatsapp / Send an Image Message
- Whatsapp / Send an Unreaction
- Whatsapp / Use a Sticker ID to Send a Sticker
- Whatsapp / Use a Sticker URL to Send a Sticker
チュートリアル
ユースケース
- Real-time data feed into multiple channels using Messages API
- Receive product information automatically via Facebook Messenger