< Back
Integrations

Guide: Create Klaviyo webhook

Insert SMS webhooks into your Klaviyo flows. Then inMobile makes sure your text messages are sent quickly, securely and automatically. See how here.

There are two ways to send SMS in Klaviyo with inMobile: via inMobile's direct integration or via a webhook in Klaviyo's flow builder.

With the direct integration, you can send SMS messages from the inMobile platform based on data synchronised from Klaviyo. If you want to set up inMobile's Klaviyo integration, check out our guide: Set up Klaviyo integration.

Do you want to insert SMS broadcasts directly into your Klaviyo flows - alongside your automated emails - but still let inMobile ensure that your messages are delivered correctly? Then you do it via a webhook.

Watch the video above or read our step-by-step guide below and learn how to insert webhooks for SMS in Klaviyo.

How to use webhooks in Klaviyo

It may look difficult, but we promise - it's not. Below you'll learn step-by-step how to set up a webhook for SMS in the Klaviyo flow builder.

How to make a webhook for SMS in Klaviyo

  1. Log in to your Klaviyo account and open the flow where you want to insert SMS.
  2. In the left menu you will find the "Webhook" tab. Drag the element into your flow at the point where you want to send an SMS message.
  3. Insert your API URL followed by your API key
    Click on your webhook element in the flow, go to the left menu and find the "Add the destination URL" field.

    Here you need to insert your API URL and replace [your api key here] with your own unique API key that you create in your inMobile account.

    Your API URL: https://api.inmobile.com/v4/sms/outgoing?apikey=[your API key here]

    3.1 Create your unique API key in inMobile
    You do this in your inMobile account -> API -> API keys -> Generate new API key. Copy the API key and paste it at the end of your API URL.
  4. Insert webhook script and customise the text
    Once you have entered your API URL and unique API key, scroll down to the "JSON BODY" section. Here you insert the following JSON script:
      
       {
      "messages": [
       {
        "to": "{{ person.phone_number }}",
        "countryHint": "45",
        "from": "inMobile",
        "text": "Hi {{ person.first_name }}. \nThis is a test SMS with line breaks. \nDbh. inMobile \nUnsubscribe: s.inmobile.com"
       }
      ]
    }
      
    
    Customise the script so you get the right sender, recipient and content in the message. Do this in a text document, as it is more manageable than editing the script directly in Klaviyo.

    There are 4 elements in the text you need to customise:

    1."to" = recipient's phone number
    When you copy the text above, it says {{ person.phone_number }} - this is Klaviyo's default mobile number field. If you keep this, the message will be sent to the number in the contacts' phone number field in Klaviyo. If you are using a custom property to collect phone numbers, you should insert the custom property here instead.

    2. "countryHint" = country code match
    CountryHint is a fallback for country code. If you have country codes on your contacts' phone numbers, they must not contradict the country code in the countryHint line - the message will not be delivered.

    Use countryHint if:
    - your contacts' phone numbers are stored without a country code
    - you only send SMS to one country per campaign/flow

    Do not use countryHint if:
    - you already have country codes on all your contacts' phone numbers
    - you want to send your SMS to multiple countries in the same campaign or flow.

    If you don't want to use countryHints, you can simply delete this line from your JSON script. However, please note that if there is no country code in either CountryHint or the contact's phone number, your message will not be delivered correctly.

    3. "from" = sender
    Here you enter the name or number of the sender (max. 11 characters).

    4. "text"= message content
    Here you insert the text to be included in your SMS message. If you want to use personalisation such as the recipient's first name, insert the correct 'profile property' from Klaviyo. You can find them right below your JSON script by clicking on "View profile properties".

    ATTENTION. It is not possible to make a line break directly in your JSON script. Instead, type "/n" at the point in the text where you want to change the line. Just like in the example.
  5. Once your script is customised with the correct recipient, sender and content, copy the entire script into the "JSON BODY" field in your Klaviyo webhook.
  6. See a preview and send a test to yourself
    You should always test your send before the flow goes live. To do this, click "Preview Webhook" at the bottom of the left menu.

    Now you get a box with a preview of your message. At the bottom of this it is possible to send a test. If you make a test request, remember that your own phone number should be the recipient in the JSON script - not Klaviyo's phone number field. Otherwise you won't receive the test message, your contacts will.
  7. If you're satisfied - you're done
    Is the test satisfactory? Then simply change the "to" back to {{ person.phone_number }} or the custom property where the profile's mobile number is. Then your SMS flow is ready to go live.

Is the test satisfactory? Then simply change the "to" back to {{ person.phone_number }} or the custom property where the profile's mobile number is. Then your SMS flow is ready to go live.

⚠️ OBS. Unsubscribe link for SMS marketing

In our example message, the end of the SMS message says "Unsubscribe: s.inmobile.com".

This is inMobile's unique unsubscribe link that our recipients can use to unsubscribe from SMS. We can use a link for SMS unsubscribe because we have set up a subdomain for it inside inMobile. You can do the same. See how in our Link cancellation guide.

Do you send other links in your SMS messages via webhooks - e.g. to special categories or sales - and would you like to track clicks on these links? Then you need to follow this guide: Link tracking via API.

Integration between inMobile and Klaviyo

With the guide above, you can now create webhooks in Klaviyo and insert SMS messages directly into Klaviyo's flow builder - but this is not always the best solution.

For example, if you need to send one-off campaigns to a segment from Klaviyo, you can use inMobile's Klaviyo integration to do so directly from your inMobile account - but with data from Klaviyo.

When you integrate inMobile and Klaviyo, your data - including lists and segments - is synchronised between the two systems. This means that you can send SMS messages from inMobile to segments retrieved from your Klaviyo account.

Read more about the possibilities with inMobile's Klaviyo integration in the article: How to send SMS in Klaviyo.