Skip to content

LinkedWhatsAppBusinessAccount

Source: src/AWS/SocialMessaging/LinkedWhatsAppBusinessAccount.ts

A WhatsApp Business Account (WABA) linked to your AWS account through AWS End User Messaging Social.

import * as AWS from "alchemy/AWS";
const events = yield* AWS.SNS.Topic("WhatsAppEvents", {});
const waba = yield* AWS.SocialMessaging.LinkedWhatsAppBusinessAccount(
"Business",
{
// from the AWS End User Messaging Social console after onboarding
accountId: "waba-0123456789abcdef0123456789abcdef",
eventDestinations: [{ eventDestinationArn: events.topicArn }],
tags: { team: "growth" },
},
);

WhatsApp events (inbound messages, message status updates) are delivered exclusively to the SNS topics listed in eventDestinations — there is no separate event source for this service. Compose the resource with AWS.SNS.consumeTopicNotifications on the destination topic:

const events = yield* AWS.SNS.Topic("WhatsAppEvents", {});
const waba = yield* AWS.SocialMessaging.LinkedWhatsAppBusinessAccount(
"Business",
{
accountId: "waba-0123456789abcdef0123456789abcdef",
eventDestinations: [{ eventDestinationArn: events.topicArn }],
},
);
// inside a Lambda Function's init effect
yield* AWS.SNS.consumeTopicNotifications(events, (stream) =>
stream.pipe(
Stream.runForEach((notification) =>
Effect.log("whatsapp event", notification.Message),
),
),
);