{
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-wisdom",
  "typeName" : "AWS::Wisdom::MessageTemplate",
  "description" : "Definition of AWS::Wisdom::MessageTemplate Resource Type",
  "definitions" : {
    "ChannelSubtype" : {
      "description" : "The channel subtype this message template applies to.",
      "type" : "string",
      "enum" : [ "EMAIL", "SMS" ]
    },
    "Content" : {
      "description" : "The content of the message template.",
      "type" : "object",
      "properties" : {
        "EmailMessageTemplateContent" : {
          "$ref" : "#/definitions/EmailMessageTemplateContent"
        },
        "SmsMessageTemplateContent" : {
          "$ref" : "#/definitions/SmsMessageTemplateContent"
        }
      },
      "oneOf" : [ {
        "required" : [ "EmailMessageTemplateContent" ]
      }, {
        "required" : [ "SmsMessageTemplateContent" ]
      } ],
      "additionalProperties" : false
    },
    "EmailMessageTemplateContent" : {
      "description" : "The content of message template that applies to email channel subtype.",
      "type" : "object",
      "properties" : {
        "Subject" : {
          "description" : "The subject line, or title, to use in email messages.",
          "type" : "string",
          "minLength" : 1
        },
        "Body" : {
          "$ref" : "#/definitions/EmailMessageTemplateContentBody"
        },
        "Headers" : {
          "description" : "The email headers to include in email messages.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/EmailMessageTemplateHeader"
          },
          "uniqueItems" : true,
          "insertionOrder" : true,
          "minItems" : 0,
          "maxItems" : 15
        }
      },
      "required" : [ "Subject", "Body", "Headers" ],
      "additionalProperties" : false
    },
    "EmailMessageTemplateContentBody" : {
      "description" : "The body to use in email messages.",
      "type" : "object",
      "properties" : {
        "PlainText" : {
          "description" : "The message body, in plain text format, to use in email messages that are based on the message template. We recommend using plain text format for email clients that don't render HTML content and clients that are connected to high-latency networks, such as mobile devices.",
          "$ref" : "#/definitions/MessageTemplateBodyContentProvider"
        },
        "Html" : {
          "description" : "The message body, in HTML format, to use in email messages that are based on the message template. We recommend using HTML format for email clients that render HTML content. You can include links, formatted text, and more in an HTML message.",
          "$ref" : "#/definitions/MessageTemplateBodyContentProvider"
        }
      },
      "additionalProperties" : false
    },
    "EmailMessageTemplateHeader" : {
      "description" : "The email header to include in email messages.",
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name of the email header.",
          "type" : "string",
          "pattern" : "^[!-9;-@A-~]+$",
          "minLength" : 1,
          "maxLength" : 126
        },
        "Value" : {
          "description" : "The value of the email header.",
          "type" : "string",
          "pattern" : "[ -~]*",
          "minLength" : 1,
          "maxLength" : 870
        }
      },
      "additionalProperties" : false
    },
    "SmsMessageTemplateContent" : {
      "description" : "The content of message template that applies to SMS channel subtype.",
      "type" : "object",
      "properties" : {
        "Body" : {
          "$ref" : "#/definitions/SmsMessageTemplateContentBody"
        }
      },
      "required" : [ "Body" ],
      "additionalProperties" : false
    },
    "SmsMessageTemplateContentBody" : {
      "description" : "The body to use in SMS messages.",
      "type" : "object",
      "properties" : {
        "PlainText" : {
          "$ref" : "#/definitions/MessageTemplateBodyContentProvider"
        }
      },
      "additionalProperties" : false
    },
    "MessageTemplateBodyContentProvider" : {
      "description" : "The container of message template body.",
      "type" : "object",
      "properties" : {
        "Content" : {
          "type" : "string",
          "minLength" : 1
        }
      },
      "additionalProperties" : false
    },
    "MessageTemplateAttributes" : {
      "description" : "An object that specifies the default values to use for variables in the message template. This object contains different categories of key-value pairs. Each key defines a variable or placeholder in the message template. The corresponding value defines the default value for that variable.",
      "type" : "object",
      "properties" : {
        "SystemAttributes" : {
          "$ref" : "#/definitions/SystemAttributes"
        },
        "AgentAttributes" : {
          "$ref" : "#/definitions/AgentAttributes"
        },
        "CustomerProfileAttributes" : {
          "$ref" : "#/definitions/CustomerProfileAttributes"
        },
        "CustomAttributes" : {
          "$ref" : "#/definitions/CustomAttributes"
        }
      },
      "additionalProperties" : false
    },
    "SystemAttributes" : {
      "description" : "The system attributes that are used with the message template.",
      "type" : "object",
      "properties" : {
        "Name" : {
          "description" : "The name of the task.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "CustomerEndpoint" : {
          "description" : "The CustomerEndpoint attribute.",
          "$ref" : "#/definitions/SystemEndpointAttributes"
        },
        "SystemEndpoint" : {
          "description" : "The SystemEndpoint attribute.",
          "$ref" : "#/definitions/SystemEndpointAttributes"
        }
      },
      "additionalProperties" : false
    },
    "SystemEndpointAttributes" : {
      "description" : "The system endpoint attributes that are used with the message template.",
      "type" : "object",
      "properties" : {
        "Address" : {
          "description" : "The customer's phone number if used with customerEndpoint, or the number the customer dialed to call your contact center if used with systemEndpoint.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        }
      },
      "additionalProperties" : false
    },
    "AgentAttributes" : {
      "description" : "The agent attributes that are used with the message template.",
      "type" : "object",
      "properties" : {
        "FirstName" : {
          "description" : "The agent’s first name as entered in their Amazon Connect user account.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "LastName" : {
          "description" : "The agent’s last name as entered in their Amazon Connect user account.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        }
      },
      "additionalProperties" : false
    },
    "CustomerProfileAttributes" : {
      "description" : "The customer profile attributes that are used with the message template.",
      "type" : "object",
      "properties" : {
        "ProfileId" : {
          "description" : "The unique identifier of a customer profile.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ProfileARN" : {
          "description" : "The ARN of a customer profile.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "FirstName" : {
          "description" : "The customer's first name.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MiddleName" : {
          "description" : "The customer's middle name.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "LastName" : {
          "description" : "The customer's last name.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "AccountNumber" : {
          "description" : "A unique account number that you have given to the customer.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "EmailAddress" : {
          "description" : "The customer's email address, which has not been specified as a personal or business address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "PhoneNumber" : {
          "description" : "The customer's phone number, which has not been specified as a mobile, home, or business number.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "AdditionalInformation" : {
          "description" : "Any additional information relevant to the customer's profile.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "PartyType" : {
          "description" : "The customer's party type.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BusinessName" : {
          "description" : "The name of the customer's business.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BirthDate" : {
          "description" : "The customer's birth date.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Gender" : {
          "description" : "The customer's gender.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MobilePhoneNumber" : {
          "description" : "The customer's mobile phone number.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "HomePhoneNumber" : {
          "description" : "The customer's home phone number.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BusinessPhoneNumber" : {
          "description" : "The customer's business phone number.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BusinessEmailAddress" : {
          "description" : "The customer's business email address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Address1" : {
          "description" : "The first line of a customer address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Address2" : {
          "description" : "The second line of a customer address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Address3" : {
          "description" : "The third line of a customer address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Address4" : {
          "description" : "The fourth line of a customer address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "City" : {
          "description" : "The city in which a customer lives.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "County" : {
          "description" : "The county in which a customer lives.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Country" : {
          "description" : "The country in which a customer lives.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "PostalCode" : {
          "description" : "The postal code of a customer address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Province" : {
          "description" : "The province in which a customer lives.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "State" : {
          "description" : "The state in which a customer lives.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingAddress1" : {
          "description" : "The first line of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingAddress2" : {
          "description" : "The second line of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingAddress3" : {
          "description" : "The third line of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingAddress4" : {
          "description" : "The fourth line of a customer’s shipping address",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingCity" : {
          "description" : "The city of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingCounty" : {
          "description" : "The county of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingCountry" : {
          "description" : "The country of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingPostalCode" : {
          "description" : "The postal code of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingProvince" : {
          "description" : "The province of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "ShippingState" : {
          "description" : "The state of a customer’s shipping address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingAddress1" : {
          "description" : "The first line of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingAddress2" : {
          "description" : "The second line of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingAddress3" : {
          "description" : "The third line of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingAddress4" : {
          "description" : "The fourth line of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingCity" : {
          "description" : "The city of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingCounty" : {
          "description" : "The county of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingCountry" : {
          "description" : "The country of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingPostalCode" : {
          "description" : "The postal code of a customer’s mailing address",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingProvince" : {
          "description" : "The province of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "MailingState" : {
          "description" : "The state of a customer’s mailing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingAddress1" : {
          "description" : "The first line of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingAddress2" : {
          "description" : "The second line of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingAddress3" : {
          "description" : "The third line of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingAddress4" : {
          "description" : "The fourth line of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingCity" : {
          "description" : "The city of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingCounty" : {
          "description" : "The county of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingCountry" : {
          "description" : "The country of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingPostalCode" : {
          "description" : "The postal code of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingProvince" : {
          "description" : "The province of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "BillingState" : {
          "description" : "The state of a customer’s billing address.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        },
        "Custom" : {
          "$ref" : "#/definitions/CustomAttributes"
        }
      },
      "additionalProperties" : false
    },
    "CustomAttributes" : {
      "description" : "The custom attributes that are used with the message template.",
      "type" : "object",
      "patternProperties" : {
        "^[a-zA-Z0-9\\s._:/=+@-]*$" : {
          "description" : "Value of a custom attribute.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 32767
        }
      },
      "additionalProperties" : false
    },
    "GroupingConfiguration" : {
      "description" : "The configuration information of the user groups that the message template is accessible to.",
      "type" : "object",
      "properties" : {
        "Criteria" : {
          "description" : "The criteria used for grouping Amazon Q in Connect users.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 100
        },
        "Values" : {
          "description" : "The list of values that define different groups of Amazon Q in Connect users.",
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/GroupingValue"
          },
          "insertionOrder" : true,
          "uniqueItems" : true
        }
      },
      "required" : [ "Criteria", "Values" ],
      "additionalProperties" : false
    },
    "GroupingValue" : {
      "description" : "The value that define the group of Amazon Q in Connect users.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 2048
    },
    "AttachmentUrl" : {
      "description" : "The S3 Presigned URL for the attachment file. When generating the PreSignedUrl, please ensure that the expires-in time is set to 30 minutes. The URL can be generated through the AWS Console or through the AWS CLI (https://docs.aws.amazon.com/AmazonS3/latest/userguide/ShareObjectPreSignedURL.html). ",
      "type" : "string",
      "minLength" : 1
    },
    "AttachmentName" : {
      "description" : "The name of the attachment file being uploaded. The name should include the file extension.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 255
    },
    "MessageTemplateAttachment" : {
      "description" : "",
      "type" : "object",
      "properties" : {
        "AttachmentId" : {
          "type" : "string",
          "minLength" : 1
        },
        "AttachmentName" : {
          "$ref" : "#/definitions/AttachmentName"
        },
        "S3PresignedUrl" : {
          "$ref" : "#/definitions/AttachmentUrl"
        }
      },
      "additionalProperties" : false,
      "required" : [ "AttachmentName", "S3PresignedUrl" ]
    },
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "properties" : {
        "Key" : {
          "description" : "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -",
          "type" : "string",
          "pattern" : "^(?!aws:)[a-zA-Z+-=._:/]+$",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "description" : "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    }
  },
  "properties" : {
    "KnowledgeBaseArn" : {
      "description" : "The Amazon Resource Name (ARN) of the knowledge base to which the message template belongs.",
      "type" : "string",
      "pattern" : "^arn:[a-z-]*?:wisdom:[a-z0-9-]*?:[0-9]{12}:[a-z-]*?/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}(?:/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})?$"
    },
    "MessageTemplateId" : {
      "description" : "The unique identifier of the message template.",
      "type" : "string",
      "pattern" : "^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$"
    },
    "MessageTemplateArn" : {
      "description" : "The Amazon Resource Name (ARN) of the message template.",
      "type" : "string",
      "pattern" : "^arn:[a-z-]*?:wisdom:[a-z0-9-]*?:[0-9]{12}:[a-z-]*?/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}(?:/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})?$"
    },
    "Name" : {
      "description" : "The name of the message template.",
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9\\\\s_.,-]+",
      "minLength" : 1,
      "maxLength" : 255
    },
    "ChannelSubtype" : {
      "$ref" : "#/definitions/ChannelSubtype"
    },
    "Content" : {
      "$ref" : "#/definitions/Content"
    },
    "Description" : {
      "description" : "The description of the message template.",
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9\\\\s_.,-]+",
      "minLength" : 1,
      "maxLength" : 255
    },
    "Language" : {
      "description" : "The language code value for the language in which the message template is written. The supported language codes include de_DE, en_US, es_ES, fr_FR, id_ID, it_IT, ja_JP, ko_KR, pt_BR, zh_CN, zh_TW",
      "type" : "string",
      "minLength" : 2,
      "maxLength" : 5
    },
    "GroupingConfiguration" : {
      "$ref" : "#/definitions/GroupingConfiguration"
    },
    "DefaultAttributes" : {
      "$ref" : "#/definitions/MessageTemplateAttributes"
    },
    "MessageTemplateContentSha256" : {
      "description" : "The content SHA256 of the message template.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 64
    },
    "MessageTemplateAttachments" : {
      "description" : "List of message template attachments",
      "type" : "array",
      "insertionOrder" : true,
      "items" : {
        "$ref" : "#/definitions/MessageTemplateAttachment"
      }
    },
    "Tags" : {
      "description" : "The tags used to organize, track, or control access for this resource. For example, { \"tags\": {\"key1\":\"value1\", \"key2\":\"value2\"} }.",
      "insertionOrder" : false,
      "uniqueItems" : true,
      "items" : {
        "$ref" : "#/definitions/Tag"
      },
      "type" : "array"
    }
  },
  "required" : [ "KnowledgeBaseArn", "ChannelSubtype", "Name", "Content" ],
  "readOnlyProperties" : [ "/properties/MessageTemplateId", "/properties/MessageTemplateArn", "/properties/MessageTemplateContentSha256", "/properties/MessageTemplateAttachments/*/AttachmentId" ],
  "writeOnlyProperties" : [ "/properties/MessageTemplateAttachments/*/S3PresignedUrl" ],
  "createOnlyProperties" : [ "/properties/KnowledgeBaseArn", "/properties/ChannelSubtype" ],
  "primaryIdentifier" : [ "/properties/MessageTemplateArn" ],
  "additionalProperties" : false,
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : false,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "wisdom:TagResource", "wisdom:UntagResource" ]
  },
  "replacementStrategy" : "create_then_delete",
  "handlers" : {
    "create" : {
      "permissions" : [ "wisdom:CreateMessageTemplate", "wisdom:GetMessageTemplate", "wisdom:TagResource", "connect:SearchRoutingProfiles", "connect:DescribeRoutingProfile", "wisdom:CreateMessageTemplateAttachment", "wisdom:DeleteMessageTemplateAttachment" ]
    },
    "update" : {
      "permissions" : [ "wisdom:UpdateMessageTemplate", "wisdom:UpdateMessageTemplateMetadata", "wisdom:GetMessageTemplate", "wisdom:TagResource", "wisdom:UntagResource", "connect:SearchRoutingProfiles", "connect:DescribeRoutingProfile", "wisdom:CreateMessageTemplateAttachment", "wisdom:DeleteMessageTemplateAttachment" ]
    },
    "delete" : {
      "permissions" : [ "wisdom:DeleteMessageTemplate", "wisdom:UntagResource", "wisdom:DeleteMessageTemplateAttachment" ]
    },
    "list" : {
      "handlerSchema" : {
        "properties" : {
          "KnowledgeBaseArn" : {
            "$ref" : "resource-schema.json#/properties/KnowledgeBaseArn"
          }
        },
        "required" : [ "KnowledgeBaseArn" ]
      },
      "permissions" : [ "wisdom:ListMessageTemplates" ]
    },
    "read" : {
      "permissions" : [ "wisdom:GetMessageTemplate" ]
    }
  }
}