Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including a clickable link in sms message using Twilio

Tags:

sms

twilio

I have a Twilio number that is setup to execute a webhook when a message is received. I would like to include a link in the response I send back to the user. ie.

Please login to XYZ.com at https://login.xyz.com/?client=SMS&userid=abc

However, when i send this in reply I get a schema validation error in the Twilio debugger with the following message.

Warning - 12200

Schema validation warning

The provided XML does not conform to the Twilio Markup XML schema. Please refer to the specific error and correct the problem.

This is the message body:

<Response>
    <Message>Please login to Botler at 'https://login.xyz.com/?client=Twilio&userid=foobar'</Message>
</Response>

I tried url encoding the url and I no longer get a schema validation error however the link in the sms is not clickable (it contains all of the escape characters).

How can i send a link in SMS and have it be clickable by the user?

Thanks.

Solution

After much trial and error I found a solution that works. I can wrap the url in CDATA element and it passes schema validation and the link is correctly interpreted by phones. For example,

<Response>
    <Message>Please login to Botler at <![CDATA[https://login.xyz.com/?client=Twilio&userid=foobar]]></Message>
</Response>
like image 472
Drew Avatar asked Jul 21 '16 16:07

Drew


1 Answers

The SMS is just text. The device has to get that text and detect that is a link to make it clickeable.

Following the doc here the problem is caused by:

  • misspelled verbs
  • incorrect case for verbs
  • misspelled or unknown attributes
  • unknown or unexpected nested elements.

Hope this help.

like image 92
Angel Guevara Avatar answered Oct 17 '22 05:10

Angel Guevara