Developer forum

Forum » Dynamicweb 10 » Sending transactional SMS with DW10

Sending transactional SMS with DW10

Simen Mindrebøe
Reply

Hi everyone,

In DynamicWeb 9 we could use the built-in SMS provider integration to send transactional SMS (order confirmations, shipping updates, etc.).
In DynamicWeb 10, the SMS provider have been deprecated, and I can’t find any updated documentation on how SMS is expected to be handled going forward.

We have a project that want to use Klaviyo for transactional SMS and we are looking for some guidance on the recommended approach in DW10.

Our goal:
Send transactional SMS from Klaviyo triggered by events coming from DynamicWeb 10 - for example, when an order is completed or when order status changes.

Questions for the community:

  1. What is the recommended way in DW10 to hook into events like order completed, order updated, or user updated - Notification subscribers, middleware, or something else?
  2. Is there an official or recommended pattern for sending custom HTTP requests from DW10 to external systems (e.g., Klaviyo Events API)?
  3. Has anyone implemented a DW10 → Klaviyo integration for SMS or email flows and can share best practices or pitfalls?
  4. Any examples of how you would structure a custom event sender in DW10 to push order data, profile phone number, and consent state to Klaviyo?

Since the SMS provider system is no longer available in DW10, we assume the solution is to push events to Klaviyo and let Klaviyo handle the actual SMS sending — but we’d appreciate any guidelines or examples on how to set this up.

Thanks in advance for any insights or code samples!

Br Simen


Replies

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Simen,

Maybe you can try a service that would send SMS based on emails, and then you can trigger the emails with DW standard notifications.
This is the approach I used for an estimate for one of our customers. It is not implemented yet, but it seems to be working.

Adrian

 
Simen Mindrebøe
Reply

Thanks Adrian! I get how the email > SMS trick could work for some gateways.

For this project we need to use Klaviyo, and they only send transactional SMS when they receive an API event, not from inbound emails. So we’d lose all the useful stuff in Klaviyo if we routed it through emails.

Since DW10 dropped the old SMS providers, I’m guessing the “right” way now is something like:

  • Hook into DW10 notifications (order completed, status changed, etc.)
  • Send a direct HTTP request to Klaviyo’s Events API
  • Let Klaviyo handle the SMS flow

If anyone here has done DW10 > external API calls or built custom notification subscribers, I’d really appreciate any tips or examples.

Thanks again!

Br Simen

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I've done this for a Klaviyo implementation. Something along these lines:

1. Subscribe to CheckoutDoneOrderIsComplete

var klaviyoApi = new KlaviyoService(apiKey, _logService);
klaviyoApi.RegisterPlacedOrderEvent(checkOutComplete.Order);

foreach (var orderLine in checkOutComplete.Order.OrderLines)
{
  klaviyoApi.RegisterOrderedProductEvent(orderLine);
}

2. In the KlaviyoService class, build a KlaviyoEvent model of type event and add order base data and lines:

    private static EventModel<OrderModel> CreateOrderModel(Order order, EventEnum @event)
    {
      var eventModel = new EventModel<OrderModel>
      {
        Attributes = new EventAttributes<OrderModel>
        {
          Metric = new Metric(@event),
          Value = order.Price.PriceWithVAT.ToStringWitDot(),
          ValueCurrency = order.CurrencyCode,
          Profile =
          {
            UserProfile = order.BuildUserProfile()
          },
          Properties = new OrderModel
          {
            Items = order.OrderLines.GetItems(),
            Categories = order.OrderLines.GetCategories(),
            ItemNames = order.OrderLines.GetItemNames(),
            OrderId = order.Id,
            BillingAddress = order.GetBillingAddress(),
            ShippingAddress = order.GetShippingAddress()
          }
        }
      };
      

where EventModel looks like this:

 public class EventModel<T>
 {
   [JsonProperty("type")]
   public string Type => "event";

   [JsonProperty("attributes")]
   public EventAttributes<T> Attributes { get; set; } = new EventAttributes<T>();

   public string Serialize()
   {
     return SerializeHelper.Serialize(this);
   }

   public string GetName()
   {
     return Attributes.Metric.Data.Attributes.Name.ToString();
   }
 }

You also need to to submit each order line separately. Never fully understood why but it seems to work OK for us:

    private static EventModel<OrderedProductModel> CreateOrderedProductModel(OrderLine orderLine)
    {
      var eventModel = new EventModel<OrderedProductModel>
      {
        Attributes = new EventAttributes<OrderedProductModel>
        {
          Metric = new Metric(EventEnum.OrderedProduct),
          Value = orderLine.Price.Price.ToStringWitDot(),
          Properties = new OrderedProductModel
          {
            OrderId = orderLine.OrderId,
            ProductId = orderLine.ProductId,
            Sku = orderLine.ProductNumber,
            Quantity = Convert.ToInt32(orderLine.Quantity),
            ProductName = orderLine.ProductName,
            Categories = orderLine.GetCategories()
          },
          Profile =
          {
            UserProfile = orderLine.Order.BuildUserProfile()
          }
        }
      };

      return eventModel;
    }

This code uses some helper methods. I can show them but they also largely depend on what it is you want to send.

    public static List<string> GetCategories(this OrderLine orderLine)
    {
      return orderLine.Product?.Groups?.Select(g => g.Name).Distinct().ToList();
    }

    public static UserProfile BuildUserProfile(this Order order)
    {
      var userModel = new UserProfile
      {
        UserAttributes = new UserAttributes
        {
          FirstName = order.FirstName(),
          LastName = order.LastName(),
          Email = order.CustomerEmail,
          PhoneNumber = order.CustomerPhone,
          ExternalId = order.CustomerAccessUserId > 0 ? order.CustomerAccessUserId.ToString() : null,
          Location =
          {
            City = order.CustomerCity,
            Country = order.CustomerCountry,
            Zip = order.CustomerZip
          }
        }
      };
      return userModel;
    }

UserAttributes is a class with properties for name, address and so on.

It's been a while so I don't remember all the details, but I can help you figure it out if you need more help.

And instead of building it all yourself, maybe one these packages can help you get started: https://www.nuget.org/packages?q=Klaviyo&includeComputedFrameworks=true&prerel=true

Hope this helps,

Imar

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

And in addition to this, you can use Twilio for sending your own SMS messages from various DynamicWeb subscribers

 

You must be logged in to post in the forum