Menu

Expand
Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Rich Messaging Features in the Twilio API for WhatsApp

When you build with the WhatsApp Business API with Twilio, you get access to several WhatsApp-specific features to dress up your messages and make it easier for your end users to reach you.

These features include:

  • Formatting message text
  • Including location information
  • Displaying previews of web links
  • QR Codes and Short Links
  • Deep Links

Formatting in WhatsApp Messages

WhatsApp allows text, emojis, and some formatting in messages. To format all or part of a message, use these formatting symbols:

Formatting Symbol Example
Bold Asterisk (**) Your total is *$10.50*.
Italic Underscore (_) Welcome to _WhatsApp_!
Strike-through Tilde (~) This is ~better~ best!
Code / Pre-formatted Three backticks (```) ```print 'Hello World';```

WhatsApp message displaying italics, strike-through, and bolding

        
        
        
        
        Use symbols to format your WhatsApp messaage

        Send a formatted WhatsApp message

        Use symbols to format your WhatsApp messaage

        Location Messages with WhatsApp

        Sending outbound location messages over WhatsApp is similar to sending a text-based message, with the addition of the PersistentAction parameter in your Twilio API requests, with must include the following information:

        • Body={name}
        • PersistentAction=geo:{latitude},{longitude} OR
        • PersistentAction=geo:{latitude},{longitude}|{label}
        Name Type Required Description
        name String Yes (for outbound messages)

        The name of the location being sent.(Location must exist in Google maps for the hyperlink to work on Mac/Windows WhatsApp client)

        latitude Number Yes
        Latitude of the location being sent
        longitude Number Yes Longitude of the location being sent
        label String No Optional free-form text to display under the location name

        WhatsApp Message Templates do not support location messaging at this time. Location messages are only supported within session messages, within the 24-hour session window of receiving an inbound message from a customer over WhatsApp. If the session has expired, you must wait for a new inbound message to trigger a new session before sending customers a location message.

        You can also receive inbound location messages with the Twilio API for WhatsApp. Locations will not show up in the Twilio Console at this time. However, your web application will receive the location data in the POST request that Twilio sends.

        Below is a sample payload containing location information. Please note that the Body={name} parameter is not required for inbound messages.

        Latitude=37.7879277&Longitude=-122.3937508&Address=375+Beale+St%2C+San+Francisco%2C+CA+94105&SmsMessageSid=SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&NumMedia=0&SmsSid=SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&Label=Twilio+Inc&Body=&To=whatsapp%3A%2B14155238886&NumSegments=1&MessageSid=SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&AccountSid=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&From=whatsapp%3A%2B12345678900&ApiVersion=2010-04-01
        

        WhatsApp message containing location information, it shows a map for 375 Beale St in San Francisco

              
              
              
              
              Use the persistent_action parameter

              Send a WhatsApp message with location information

              Use the persistent_action parameter

              Preview weblinks in freeform WhatsApp messages

              When you are within the 24-hour session (initiated by a customer sending your business a message), you can send freeform, non-templated messages with a customer. During this 24-hour window, WhatsApp messages that contain web links display a web page snippet preview on the WhatsApp client.

              WhatsApp message with link that also displays a preview of the link

              Start conversations with deep links

              Customers can initiate a conversation with you on WhatsApp through URL deep links, such as on your website. If end users have WhatsApp installed on their devices, clicking the deep link opens a conversation with your business inside of WhatsApp.

              Deep link format : whatsapp://send?phone=<e164 number>&text=Hello!

              Deep links can be embedded in web or mobile apps, advertised on the web, or placed in other visible locations. They are an effective way to start conversations without using WhatsApp Notification templates.

              QR Codes and Short Links

              QR codes and short links enable consumers to initiate a conversation with a business without adding a new contact in their phone!

              What are QR codes?

              A QR ("Quick Response") code is a type of barcode that you can use to open up a new WhatsApp conversation. Your end uses can scan your business' QR code, and the WhatsApp business profile will automatically load, with a pre-filled message that your business can define.

              Here’s an example of a QR Code:

              sample_whatsapp_qr_code.png

              What are Short links?

              Businesses can generate short links that, when clicked, load pre-filled messages. You can edit or delete these links at any time. Short links mask phone numbers so that only a random code appears in the url.

              How can businesses use QR codes and short links?

              • Get in touch with more users. Businesses can place QR codes on product packaging, receipts/invoices, at your storefront and other physical or digital surfaces. These can be used to respond to customer-initiated questions, such as pre-sales inquiries or post-purchase support.
              • Collect opt-in. Businesses can collect opt-in for notifications via QR codes and/or short links.

              What's Next?

              Ready to send feature-rich messages to your end users over WhatsApp? Check out some of these resources to get started (or keep) building:

              Rate this page:

              Need some help?

              We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.