Skip to content

SendWhatsAppMessage

Source: src/AWS/SocialMessaging/SendWhatsAppMessage.ts

Runtime binding for social-messaging:SendWhatsAppMessage.

Sends a WhatsApp message (text, template, media, or interactive) from one of the linked account’s phone numbers. The message blob is the raw Meta Cloud API message payload and is sensitive — pass it as a Uint8Array or Redacted<Uint8Array>.

The caller addresses one of the bound account’s phone numbers per request; phone-number ARNs are provisioned by Meta under the WABA, so the deploy-time half grants social-messaging:SendWhatsAppMessage on *. Provide the implementation with Effect.provide(AWS.SocialMessaging.SendWhatsAppMessageHttp).

// init — bind the operation to the linked WABA
const sendMessage = yield* AWS.SocialMessaging.SendWhatsAppMessage(account);
// runtime
const { messageId } = yield* sendMessage({
originationPhoneNumberId: "phone-number-id-0123456789abcdef",
metaApiVersion: "v20.0",
message: new TextEncoder().encode(
JSON.stringify({
messaging_product: "whatsapp",
to: "+12065550100",
type: "text",
text: { body: "Hello from Alchemy" },
}),
),
});