지원 종료 공지: 2026년 10월 30일에 AWS 는 Amazon Pinpoint에 대한 지원을 종료합니다. 2026년 10월 30일 이후에는 Amazon Pinpoint 콘솔 또는 Amazon Pinpoint 리소스(엔드포인트, 세그먼트, 캠페인, 여정, 분석)에 더 이상 액세스할 수 없습니다. 자세한 내용은 Amazon Pinpoint 지원 종료를 참조하세요. 참고: SMS, 음성, 모바일 푸시, OTP 및 전화번호 검증과 관련된 APIs는이 변경의 영향을 받지 않으며 AWS 최종 사용자 메시징에서 지원됩니다.
기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.
Amazon Pinpoint 캠페인에 대한 Lambda 함수 생성 및 구성
이 섹션에서는 사용자 지정 채널을 통해 메시지를 보내는 Lambda 함수를 만드는 단계를 개략적으로 설명합니다. 먼저 함수를 만듭니다. 그런 다음 함수에 실행 정책을 추가합니다. 이 정책은 캠페인이 실행될 때 Amazon Pinpoint가 정책을 실행하도록 허용합니다.
Lambda 함수 생성에 대한 소개는 AWS Lambda 개발자 안내서의 Lambda 함수 빌드를 참조하세요.
Lambda 함수 예제
다음 코드 예제에서는 페이로드를 처리하고 CloudWatch에 각 엔드포인트 유형의 엔드포인트 수를 기록합니다.
import boto3 import random import pprint import json import time cloudwatch = boto3.client('cloudwatch') def lambda_handler(event, context): customEndpoints = 0 smsEndpoints = 0 pushEndpoints = 0 emailEndpoints = 0 voiceEndpoints = 0 numEndpoints = len(event['Endpoints']) print("Payload:\n", event) print("Endpoints in payload: " + str(numEndpoints)) for key in event['Endpoints'].keys(): if event['Endpoints'][key]['ChannelType'] == "CUSTOM": customEndpoints += 1 elif event['Endpoints'][key]['ChannelType'] == "SMS": smsEndpoints += 1 elif event['Endpoints'][key]['ChannelType'] == "EMAIL": emailEndpoints += 1 elif event['Endpoints'][key]['ChannelType'] == "VOICE": voiceEndpoints += 1 else: pushEndpoints += 1 response = cloudwatch.put_metric_data( MetricData = [ { 'MetricName': 'EndpointCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': len(event['Endpoints']) }, { 'MetricName': 'CustomCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': customEndpoints }, { 'MetricName': 'SMSCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': smsEndpoints }, { 'MetricName': 'EmailCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': emailEndpoints }, { 'MetricName': 'VoiceCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': voiceEndpoints }, { 'MetricName': 'PushCount', 'Dimensions': [ { 'Name': 'CampaignId', 'Value': event['CampaignId'] }, { 'Name': 'ApplicationId', 'Value': event['ApplicationId'] } ], 'Unit': 'None', 'Value': pushEndpoints }, { 'MetricName': 'EndpointCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': len(event['Endpoints']) }, { 'MetricName': 'CustomCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': customEndpoints }, { 'MetricName': 'SMSCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': smsEndpoints }, { 'MetricName': 'EmailCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': emailEndpoints }, { 'MetricName': 'VoiceCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': voiceEndpoints }, { 'MetricName': 'PushCount', 'Dimensions': [ ], 'Unit': 'None', 'Value': pushEndpoints } ], Namespace = 'PinpointCustomChannelExecution' ) print("cloudwatchResponse:\n",response)
Amazon Pinpoint 캠페인이 이 Lambda 함수를 실행하면 Amazon Pinpoint는 세그먼트 멤버의 목록을 함수에 보냅니다. 이 함수는 각 ChannelType의 엔드포인트 수를 계산합니다. 그런 다음, 해당 데이터를 Amazon CloudWatch로 보냅니다. CloudWatch 콘솔의 지표 섹션에서 이러한 지표를 볼 수 있습니다. 지표는 PinpointCustomChannelExecution 네임스페이스에서 사용할 수 있습니다.
이 코드 예제를 수정하여 외부 서비스의 API에도 연결하여 해당 서비스를 통해 메시지를 보낼 수 있습니다.