<@U04UQ68083H> what is the tel validation for ory ...
# ory-copilot
r
@chilly-king-10285 what is the tel validation for ory kratos? i’ve input
60123456789
which should be a valid phone number, and it return is not valid \“tel\”
b
A message from kapa.ai
Ory Kratos uses the
"format": "tel"
field in the identity schema to validate phone numbers. This validation is performed using the Go port of Google's [libphonenumber](https://github.com/google/libphonenumber) library, which is a widely used standard for phone number validation. The relevant documentation states: > By using the
"format": "tel"
field we enable validation of phone numbers using the Golang port of Google's libphonenumber. This means that the phone number you provide (e.g.,
60123456789
) must be in a format recognized as valid by libphonenumber. Typically, libphonenumber expects phone numbers in E.164 format, which usually starts with a
+
followed by the country code and the subscriber number (e.g.,
+60123456789
for Malaysia). If you input
60123456789
(without the
+
), it may not be recognized as valid. Try using the E.164 format:
+60123456789
instead. If you continue to experience issues, ensure that your schema is correctly set up with
"format": "tel"
for the phone trait and that the input matches the expected format for your country code and number length as per libphonenumber's rules [Phone number](https://www.ory.sh/docs/kratos/manage-identities/customize-identity-schema#phone-number).
r
@chilly-king-10285 I’m getting this error
Expected sms template but got <nil>
b
A message from kapa.ai
The error
Expected sms template but got <nil>
typically means that Ory Kratos is trying to send an SMS (for example, for verification, login, or recovery), but it cannot find a configured SMS template for the message type it needs to send. To resolve this, you need to ensure that you have configured the required SMS templates in your Ory Identities configuration. Only the
recovery_code
,
verification_code
, and
login_code
templates support an SMS variant. Here’s how you can add them: 1. Download your Ory Identities config. 2. Add the SMS templates under the
courier.templates
section. For example:
Copy code
yaml courier:   templates:     verification_code:       valid:         sms:           body:             plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="     login_code:       valid:         sms:           body:             plaintext: "<base64://WW91ciBsb2dpbiBjb2RlIGlzOiB7eyAuTG9naW5Db2RlIH19>"     recovery_code:       valid:         sms:           body:             plaintext: "<base64://WW91ciByZWNvdmVyeSBjb2RlIGlzOiB7eyAuUmVjb3ZlcnlDb2RlIH19CgpAe3sgLlJlcXVlc3RVUkxEb21haW4gfX0gI3t7IC5SZWNvdmVyeUNvZGUgfX0K>"
3. Upload the updated config back to Ory. If you do not provide these templates, Ory will not be able to send SMS messages and will return the error you are seeing [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). If you are using Ory Network, make sure you use Base64-encoded templates, as
http://
or
file://
URIs are not supported [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). If you have already configured the templates and still see this error, double-check that the template type (e.g.,
verification_code
) matches the flow you are triggering and that the SMS channel is properly set up. If you need more details on configuring SMS templates, refer to the official documentation [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms).
r
@chilly-king-10285 I only setup for verification_code, do I need to create for all?
b
A message from kapa.ai
No, you do not need to create SMS templates for all types—only for the flows you are actually using. For example, if you are only using SMS for verification, then only the
verification_code
SMS template is required. If you also want to support SMS for account recovery or login, you must add the
recovery_code
and/or
login_code
SMS templates as well. If you attempt to trigger a flow (like recovery or login) that sends an SMS but have not configured the corresponding template, you will encounter the
Expected sms template but got <nil>
error for that flow [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). So, only configure the SMS templates for the flows you intend to support via SMS.
r
@chilly-king-10285 I’ve added in the templates.verification_code.valid.sms.body.plaintext, but still getting the error
b
A message from kapa.ai
If you have already added the
templates.verification_code.valid.sms.body.plaintext
template and are still seeing the error
Expected sms template but got <nil>
, there are a few things to check based on the official Ory documentation: 1. Template Placement and Structure Ensure your configuration matches the required structure. The template should be under:
Copy code
yaml    courier:      templates:        verification_code:          valid:            sms:              body:                plaintext: "base64://<your_base64_encoded_template>"
Only the
recovery_code
,
verification_code
, and
login_code
templates support an SMS variant. Double-check that you are not using a different template key or structure, as other templates (like
verification.valid
) do not support SMS variants [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 2. Base64 Encoding The value for
plaintext
must be a valid base64-encoded string, and the prefix must be
base64://
. If the encoding or prefix is incorrect, the template will not be recognized [Using custom message templates](https://www.ory.sh/docs/kratos/emails-sms/custom-email-templates#using-custom-message-templates). 3. SMS Channel Configuration Make sure you have configured an SMS channel in your
courier.channels
section. Without a properly configured SMS channel, the template will not be used, and you may see this error [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 4. Flow Type Confirm that the flow you are triggering is actually using the
verification_code
template. If you are triggering a different flow (like recovery or login), you will need to provide the corresponding SMS template for that flow. If all of the above are correct and you are still experiencing the issue, the knowledge sources do not provide further troubleshooting steps for this specific error. In that case, it may be a bug or a misconfiguration not covered in the documentation, and you may want to open an issue with your configuration details for further support. Summary: - Double-check the template structure and encoding. - Ensure the SMS channel is configured. - Make sure the correct flow and template type are being used. If the problem persists after these checks, the knowledge sources do not contain enough information to provide a more specific solution.
r
@chilly-king-10285 I can see the logs have this
Sending out registration email with code.
, eventhough I register using traits.phone
b
A message from kapa.ai
Based on the knowledge sources, this behavior is a known issue when using a schema that includes both phone and email traits, each marked as verifiable (i.e., with
"verification": { "via": "sms" }
for phone and
"verification": { "via": "email" }
for email). Even if you register using
traits.phone
(SMS), Ory Kratos will still send a verification email to the email address if email verification is enabled in the schema. This is confirmed in the [GitHub issue](https://github.com/ory/kratos/issues/4161), where users report that after registering with a phone number and SMS code, a verification email is still sent. The only way to prevent this is to remove the email verification configuration from the schema:
Copy code
diff "email": {   "type": "string",   "format": "email",   "title": "E-mail",   "minLength": 3,   "<http://ory.sh/kratos|ory.sh/kratos>": {     "credentials": {       "password": {         "identifier": true       },       "code": {         "identifier": true,         "via": "email"       }     }, -    "verification": { -      "via": "email" -    }   } },
So, if both phone and email are marked as verifiable, Kratos will attempt to verify both, regardless of which trait was used for registration. This is not configurable per-flow in the current version, and is considered a limitation or bug by some users [Phone+email schema: verification email is sent when signed up with SMS code](https://github.com/ory/kratos/issues/4161). Summary: If you want to avoid sending a verification email when registering with a phone number, you must remove the email verification configuration from your identity schema. There is currently no built-in way to have Kratos only verify the trait used for registration when both are present and verifiable in the schema.
r
@chilly-king-10285 ignore the email one, but I’m stll getting this issue
Expected sms template but got <nil>
b
A message from kapa.ai
If you have removed the email verification from your schema and are still seeing the error
Expected sms template but got <nil>
, this means Ory Kratos is attempting to send an SMS (for example, for verification), but it cannot find the required SMS template for the message type. Based on the official documentation, you must ensure that: 1. The SMS template is configured for the correct template type. Only the following templates support an SMS variant: -
verification_code
-
login_code
-
recovery_code
The configuration should look like this:
Copy code
yaml    courier:      templates:        verification_code:          valid:            sms:              body:                plaintext: "base64://<your_base64_encoded_template>"
2. The template is base64-encoded and prefixed with
base64://
.
If the encoding or prefix is incorrect, Kratos will not recognize the template [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 3. You have a properly configured SMS channel. Without an SMS channel in
courier.channels
, the template will not be used [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). If all of the above are correct and you are still seeing the error, the knowledge sources do not provide further troubleshooting steps for this specific error. In that case, it may be a bug or a misconfiguration not covered in the documentation, and you may want to open an issue with your configuration details for further support. Summary: - Double-check your template structure and encoding. - Ensure the SMS channel is configured. - Make sure the correct template type is used. If the problem persists after these checks, the knowledge sources do not contain enough information to provide a more specific solution.
r
@chilly-king-10285 help me to check my yml
b
A message from kapa.ai
r
@chilly-king-10285 help me to check my yml
Copy code
courier:
  delivery_strategy: smtp
  smtp:
    connection_uri: <smtp://redacted:10025/?disable_starttls=true>
    from_address: redacted
    from_name: "redacted"
  channels:
    - id: sms
      type: http
      request_config:
        url: <https://verify.twilio.com/v2/Services/redacted/Verifications>
        method: POST
        body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==
        headers:
          Content-Type: application/x-www-form-urlencoded
  templates:
    verification_code:
      valid:
        sms:
          body:
            plaintext: "<base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ=="
        email:
          body:
            plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGU>gfX0="
b
I'm happy to help review your YAML configuration! However, I don't see your YAML file or its contents in your message. Please paste your relevant YAML configuration (especially the
courier
and
templates
sections) here, and I'll review it for issues related to the
Expected sms template but got <nil>
error. Based on the knowledge sources, here’s what you should check in your YAML: - The
courier.templates.verification_code.valid.sms.body.plaintext
field must be present and correctly formatted. - The value must be a base64-encoded string, prefixed with
base64://
. - Only the
verification_code
,
login_code
, and
recovery_code
templates support SMS variants [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). - You must have an SMS channel configured under
courier.channels
. Please paste your YAML, and I’ll review it for you!
A message from kapa.ai
Thank you for sharing your YAML. Here’s a review based on the official Ory documentation: ### Issues & Recommendations 1. Base64 Prefix Formatting - The value for
plaintext
under your SMS template should not include angle brackets (
<
and
>
). It should be:
Copy code
<base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==
not
Copy code
<base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDo>gY3R4Lm1lc3NhZ2VfdHlwZSwKfQ==>
- Remove the angle brackets from all base64 values. 2. Template Structure - Your structure for the SMS template under
verification_code
is correct. Only
verification_code
,
login_code
, and
recovery_code
support SMS templates [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms). 3. SMS Channel - You have an SMS channel configured, which is required. 4. Jsonnet Template - The base64-encoded value for the SMS body should decode to a valid Jsonnet function. Double-check that your template, when decoded, matches the expected structure:
Copy code
jsonnet      function(ctx) {        To: ctx.recipient,        Body: ctx.body,      }
- If your template is different, it may cause issues. 5. No Need for Email in SMS-Only Flows - If you are only using phone verification, you can omit the
email
section under
verification_code
if not needed. ### Example (Corrected)
Copy code
yaml courier:   delivery_strategy: smtp   smtp:     connection_uri: <smtp://redacted:10025/?disable_starttls=true>     from_address: redacted     from_name: "redacted"   channels:     - id: sms       type: http       request_config:         url: <https://verify.twilio.com/v2/Services/redacted/Verifications>         method: POST         body: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDogY3R4Lm1lc3NhZ2VfdHlwZSwKfQ>==         headers:           Content-Type: application/x-www-form-urlencoded   templates:     verification_code:       valid:         sms:           body:             plaintext: <base64://ZnVuY3Rpb24oY3R4KSB7CiAgdG86IGN0eC5yZWNpcGllbnQsCiAgY2hhbm5lbDogY3R4Lm1lc3NhZ2VfdHlwZSwKfQ>==
### Summary - Remove angle brackets from all base64 values. - Ensure your base64-encoded template decodes to a valid Jsonnet function as expected by Ory. - Your structure is otherwise correct for SMS verification. If you make these corrections and still see the error, the knowledge sources do not provide further troubleshooting steps for this specific issue. In that case, you may want to reach out to Ory support or open a GitHub issue with your configuration details. For more details, see the official documentation: [Send SMS to your users](https://www.ory.sh/docs/kratos/emails-sms/sending-sms).
r
@chilly-king-10285 apparently this is a known issue, and it has been fixed in master, but yet to release is there anyway to bypass this?
b
A message from kapa.ai
Based on the knowledge sources, this issue—where Ory Kratos expects an SMS template but fails to find it, even when configured correctly—has been reported by users and acknowledged by Ory team members as a bug. It is noted that SMS verification and recovery are not yet officially supported, but are on the backlog. There is also mention that fixes have been merged into the master branch but are not yet released in a stable version [Cannot Verify Phone](https://github.com/ory/network/issues/406). Workarounds: - One suggested workaround is to use "login with code" and SMS, which will automatically mark the phone/email as verified if the code sent to that address is used. This approach bypasses the broken verification flow by leveraging the login flow instead. However, this is not a full replacement for a dedicated verification flow and may not fit all use cases. - There is no documented configuration-based bypass for the template issue in the current stable release. The only other suggestion is to wait for the next release that includes the fix, or to build and run Kratos from the master branch if you are able to do so in your environment [Cannot Verify Phone](https://github.com/ory/network/issues/406). Summary: There is no official configuration-based bypass for this issue in the current stable release. The only available workaround is to use the login flow with code (SMS), or to use a build from the master branch where the fix is present. If this is blocking your project, you may want to monitor the release notes or reach out to Ory support for updates on the release timeline.
r
@chilly-king-10285 does Ory will create account once the registration flow being triggered
b
A message from kapa.ai
No, Ory does not create an account (identity) just by triggering or initializing the registration flow. The registration flow must be completed by submitting the required form data (such as email, password, etc.) to Ory. Only after the registration form is successfully submitted and validated does Ory create the user account (identity) [Registration](https://www.ory.sh/docs/kratos/self-service/flows/user-registration). Initializing the registration flow simply prepares the flow, runs pre-registration hooks, and sets up things like CSRF tokens, but does not persist any user data or create an account at that stage [Initialize registration flow](https://www.ory.sh/docs/kratos/self-service/flows/user-registration#initialize-registration-flow).
r
@chilly-king-10285 how about phone number registration?
b
A message from kapa.ai
For phone number registration in Ory Kratos, the process is the same as with email or username: the account (identity) is only created after the registration flow is completed and the required data is submitted and validated. Simply triggering or initializing the registration flow does not create the account. You must define the phone number as a trait in your identity schema, typically with
"format": "tel"
and, if you want verification, with the appropriate
"verification"
extension. When a user submits the registration form with their phone number (and any other required fields), and the submission passes validation, Ory will then create the identity. If phone verification is enabled, the verification process (such as sending an SMS code) will be triggered after the account is created [Phone number verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#phone-number-verification). So, the account is created only after the registration form is submitted and validated, not when the flow is merely started—this applies to phone number registration as well.
r
@chilly-king-10285 so an account will only be created after verification done?
b
A message from kapa.ai
No, an account (identity) in Ory Kratos is created **after the registration flow is successfully completed and the required data is submitted and validated**—not after verification is done. The verification process (such as verifying an email or phone number) happens after the account has been created, if verification is enabled in your schema. This means the user exists in the system even if their address is not yet verified [Registration](https://www.ory.sh/docs/kratos/self-service/flows/user-registration) [Address verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation). So, to clarify: - Account is created after registration is completed. - Verification is a separate step that happens after account creation, if required. If you require that users verify their address before they can log in or receive a session, you can configure Ory to enforce this, but the account itself is still created before verification [Verification on sign up](https://www.ory.sh/docs/actions/require-verified-address#verification-on-sign-up).