title: Event Trigger Object for AWS Cognito User Pools
body: <p>I would like to make a custom verification message for newly registered users in my AWS Cognito User Pool</p>
  
  <p>To do so, I am trying to associate a Lamda function with a "Custom message" trigger.</p>
  
  <p>However, I am not able to find the exact format of the custom message event, to be able to make my lambda function.</p>
  
  <p>The lambda function that I came up with is</p>
  
  <pre><code> exports.handler = function(event, context) {
      // 
      if(event.userPoolId === "us-east-t9....") {
  
          // Identify why was this function invoked
          if(event.triggerSource === "RegisterUser") {
              // This Lambda function was invoked because a new user signed up to the user-pool "theRequiredUserPool"
              // Ensure that your message contains event.request.codeParameter, this is the place holder for code that will be sent.
                          var link = "https://.....confirm_user.html?username="+ event.userName + "&amp;code=" + event.request.codeParameter;
              var message = "Thank you for signing up. Your confirmation code is " + event.request.codeParameter;
              message+= " Click &lt;a href='"+link+"'&gt;here to finish your registatration!";
              event.response.emailSubject = "Welcome to the service";
              event.response.emailMessage = message;
  
          }
          // Create custom message for other events
      }
      // Customize messages for other user pools
  
  
      // Return result to Cognito
      context.done(null, event);
  }
  </code></pre>
  
  <p>When I "test" my function in the Lambda console, it works, but that is because I am testing it against my own event object that I created, based on the only clue I could find in the documentation:</p>
  
  <pre><code>{  "version": 1,
    "triggerSource": "RegisterUser/ResendCode/ForgotPassword/VerifyUserAttribute",
    "region": "&lt;region&gt;",
    "userPoolId": "&lt;userPoolId&gt;",
    "userName": "&lt;userName&gt;",
    "callerContext": {
        "awsSdk": "&lt;calling aws sdk with version&gt;",
        "clientId": "&lt;apps client id&gt;",
        ...
    },
    "request": {
        "userAttributes": {
            "phone_verified": true/false,
            "email_verified": true/false,
            ... (all custom attributes)
        },
        "codeParameter": "{code}"
    },
    "response": {
        "smsMessage": "&lt;custom message to be sent in the message with code parameter&gt;"
        "emailMessage": "&lt;custom message to be sent in the message with code parameter&gt;"
        "emailSubject": "&lt;custom email subject&gt;"
    }
  }
  </code></pre>
  
  <p>from <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html" rel="nofollow">https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools-working-with-aws-lambda-triggers.html</a></p>
  
  <p>I need something more solid than that. I am not able to get my function to work and I don't know where to start. How can I implement a lambda function if I don't know what to expect in the event object? Is there any specification out there for the "Custom Message" event?</p>
  
  <p>UPDATE:
  Now that Amazon User Pool's are out of beta, since July 29, 2016, I am no longer having this problem.</p>