public CustomMessageBase FunctionHandler(CustomMessageBase cognitoCustomMessageEvent) { //LEVEL 4 - Add Custom Message Signup Workflow Trigger LambdaLogger.Log("LEVEL 4 - Add Custom Message Signup Workflow Trigger"); return(cognitoCustomMessageEvent); }
/// <summary> /// 推送客服消息 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="appId"></param> /// <param name="msg">客服消息实体</param> /// <returns></returns> public async Task <ResultReturn> SendMsg(string appId, CustomMessageBase msg) { var data = await CommonApi.Post(appId, "/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN", msg.ToJson() ); return(data); }
public async Task <JObject> FunctionHandler(JObject cognitoTriggerEvent, ILambdaContext context) { try { CustomMessageBase eventMessage = JsonConvert.DeserializeObject <CustomMessageBase>(JsonConvert.SerializeObject(cognitoTriggerEvent)); LambdaLogger.Log(eventMessage.ToJson().ToString()); switch (eventMessage.TriggerSource) { case "PostConfirmation_ConfirmSignUp": var name = eventMessage.Request.UserAttributes["name"]; var familyName = eventMessage.Request.UserAttributes["family_name"]; var email = eventMessage.Request.UserAttributes["email"]; var message = $"{{ 'name' : '{name}', 'familyName':'{familyName}', 'email':'{email}' }}"; /*var sendRequest = new SendMessageRequest(); * sendRequest.QueueUrl = Configuration.QUEUE_URL; * sendRequest.MessageBody = message; * * var amazonSQSClient = new AmazonSQSClient(); * var response = await amazonSQSClient.SendMessageAsync(sendRequest);*/ var snsClient = new AmazonSimpleNotificationServiceClient(); var request = new PublishRequest { TopicArn = Configuration.SNS_TOPIC_ARN, Message = message }; var response = await snsClient.PublishAsync(request); LambdaLogger.Log(message); LambdaLogger.Log(JsonConvert.SerializeObject(response)); break; default: LambdaLogger.Log($"No custom implementations for: {eventMessage.TriggerSource}"); break; } } catch (Exception ex) { LambdaLogger.Log($"Error: {ex.Message}"); } return(cognitoTriggerEvent); }