-
-
Save pchaozhong/c4c84e67997c71357d64156eca6a26b1 to your computer and use it in GitHub Desktop.
Amazon Connect Sample
This file contains hidden or 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
| import boto3 | |
| import os | |
| import json | |
| DESTINATION_PHONE_NUMBER = os.getenv('DESTINATION_PHONE_NUMBER') | |
| SOURCE_PHONE_NUMBER = os.getenv('SOURCE_PHONE_NUMBER') | |
| INSTANCE_ID = os.getenv('INSTANCE_ID') | |
| CONTACT_FLOW_ID = os.getenv('CONTACT_FLOW_ID') | |
| connect = boto3.client('connect') | |
| def lambda_handler(event, context): | |
| connect.start_outbound_voice_contact( | |
| DestinationPhoneNumber=DESTINATION_PHONE_NUMBER, | |
| ContactFlowId=CONTACT_FLOW_ID, | |
| InstanceId=INSTANCE_ID, | |
| SourcePhoneNumber=SOURCE_PHONE_NUMBER, | |
| Attributes={ | |
| 'message': 'これはテストメッセージです。' | |
| } | |
| ) |
This file contains hidden or 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
| import json | |
| def lambda_handler(event, context): | |
| print(json.dumps(event)) | |
| return { | |
| 'statusCode': 200 | |
| } |
This file contains hidden or 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
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: AWS::Serverless-2016-10-31 | |
| Description: AmazonConnectSample | |
| Parameters: | |
| DestinationPhoneNumber: | |
| Type: String | |
| SourcePhoneNumber: | |
| Type: String | |
| InstanceId: | |
| Type: String | |
| ContactFlowId: | |
| Type: String | |
| Globals: | |
| Function: | |
| Timeout: 5 | |
| Resources: | |
| PhonePublishFunction: | |
| Type: AWS::Serverless::Function | |
| Properties: | |
| FunctionName: phone-publish-function | |
| CodeUri: src/publish | |
| Handler: app.lambda_handler | |
| Runtime: python3.7 | |
| Environment: | |
| Variables: | |
| DESTINATION_PHONE_NUMBER: | |
| Ref: DestinationPhoneNumber | |
| SOURCE_PHONE_NUMBER: | |
| Ref: SourcePhoneNumber | |
| INSTANCE_ID: | |
| Ref: InstanceId | |
| CONTACT_FLOW_ID: | |
| Ref: ContactFlowId | |
| Role: !GetAtt PhonePublishFunctionRole.Arn | |
| PhonePublishFunctionRole: | |
| Type: AWS::IAM::Role | |
| Properties: | |
| AssumeRolePolicyDocument: | |
| Statement: | |
| - Effect: Allow | |
| Principal: | |
| Service: lambda.amazonaws.com | |
| Action: | |
| - sts:AssumeRole | |
| Path: / | |
| Policies: | |
| - PolicyName: phone-publish-function-role | |
| PolicyDocument: | |
| Statement: | |
| - Effect: Allow | |
| Action: | |
| - logs:CreateLogGroup | |
| - logs:CreateLogStream | |
| - logs:PutLogEvents | |
| Resource: '*' | |
| - Effect: Allow | |
| Action: | |
| - connect:StartOutboundVoiceContact | |
| - connect:StopContact | |
| Resource: '*' | |
| PhoneSubscribeFunction: | |
| Type: AWS::Serverless::Function | |
| Properties: | |
| FunctionName: phone-subscribe-function | |
| CodeUri: src/subscribe | |
| Handler: app.lambda_handler | |
| Runtime: python3.7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment