<@U04UQ68083H> I want to send verification codes o...
# ory-copilot
r
@chilly-king-10285 I want to send verification codes only via sms and not email. How do I configure the identity schema and the courier channel to enable this? Do I need to trigger the verification flow differently?
c
A message from kapa.ai
To send verification codes only via SMS, you need to configure your identity schema and courier channel accordingly. Firstly, in your identity schema, you need to have a trait that holds the phone number. This trait must be marked as a verifiable address via the
verification
extension. Here's an example of how to define such a trait in the identity schema:
Copy code
json {     "$id": "<https://schemas.ory.sh/presets/kratos/quickstart/phone-password/identity.schema.json>",     "$schema": "<http://json-schema.org/draft-07/schema#>",     "title": "Person",     "type": "object",     "properties": {       "traits": {         "type": "object",         "properties": {           "phone": {             "type": "string",             "title": "Phone number",             "format": "tel",             "<http://ory.sh/kratos|ory.sh/kratos>": {               "verification": {                 "via": "sms"               }             }           }         },         "additionalProperties": false       }     }   }
(Source: [Phone number verification](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#phone-number-verification)) Next, you need to configure a courier channel with the ID set to
sms
via the CLI. You can do this by adding the configuration for your custom SMTP server to your Ory Identities config file:
Copy code
yaml courier:     templates:       verification_code:         valid:           sms:             body:               plaintext: "<base64://WW91ciB2ZXJpZmljYXRpb24gY29kZSBpczoge3sgLlZlcmlmaWNhdGlvbkNvZGUgfX0>="
(Source: [Templates](https://www.ory.sh/docs/kratos/emails-sms/sending-sms#templates)) Finally, to trigger the verification flow, you need to create a new login flow with the
aal
parameter set to
aal2
and specify which trait to use for delivering the code to the user. For example, if you have a trait called
phone_number
, you'd set
via
to
phone_number
. (Source: [Integration](https://www.ory.sh/docs/kratos/mfa/mfa-via-sms#integration))