Skip to main content

Service Message

Send WhatsApp service messages with Messente's Omnichannel API.


Introduction

Service messages are a type of message that can be sent to users without the need for a pre-approved template. They are used to facilitate ongoing conversations with users. Service messages can include text, images, buttons, and other interactive elements, and they are designed to facilitate back-and-forth conversations with users. In order to be able to send service messages, you must first have a WhatsApp Business Account and a verified phone number connected to Messente using our embedded signup.

24-hour conversation window

The 24-hour conversation window is a period of time during which you can send service messages to a user without needing to use a template. This window is opened when a user interacts with your business, such as by replying to a message or clicking a button. The window remains open for 24 hours, allowing you to send multiple messages without needing to use a template. Each message sent within this window will extend the window by another 24 hours.

Sending a Service Message

To send a service message, you can use the Omnichannel API send message endpoint, similarly as for template WhatsApp messages. The key difference is that you do not need to specify a template, but rather provide the content of the message directly in the request body. The message can include text, images, buttons, and other interactive elements. Below are examples of how to send a service message using our public libraries.

Text Message

from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
WhatsApp,
OmnimessageMessagesInner,
WhatsAppText,
)
from messente_api.rest import ApiException


configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

wa_text = WhatsAppText(
body="hello, world!",
preview_url=True, # set preview_url to False if you want to disable URL previews
)

whatsapp = WhatsApp(
sender="<SENDER_NAME>",
text=wa_text,
)

whatsapp_inner = OmnimessageMessagesInner(whatsapp)
omnimessage = Omnimessage(messages=[whatsapp_inner], to="<RECIPIENT_PHONE_NUMBER>")

try:
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception when sending an omnimessage: %s\n" % exception)

Image Message

from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
WhatsApp,
OmnimessageMessagesInner,
WhatsAppImage,
)
from messente_api.rest import ApiException


configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

wa_image = WhatsAppImage(
link="<MEDIA_URL>", # URL link to the image file
)

whatsapp = WhatsApp(
sender="<SENDER_NAME>",
image=wa_image,
)

whatsapp_inner = OmnimessageMessagesInner(whatsapp)
omnimessage = Omnimessage(messages=[whatsapp_inner], to="<RECIPIENT_PHONE_NUMBER>")

try:
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception when sending an omnimessage: %s\n" % exception)

Audio Message

from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
WhatsApp,
OmnimessageMessagesInner,
WhatsAppAudio,
)
from messente_api.rest import ApiException


configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

wa_audio = WhatsAppAudio(
link="<MEDIA_URL>", # URL link to the audio file
)

whatsapp = WhatsApp(
sender="<SENDER_NAME>",
audio=wa_audio,
)

whatsapp_inner = OmnimessageMessagesInner(whatsapp)
omnimessage = Omnimessage(messages=[whatsapp_inner], to="<RECIPIENT_PHONE_NUMBER>")

try:
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception when sending an omnimessage: %s\n" % exception)

Video Message

from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
WhatsApp,
OmnimessageMessagesInner,
WhatsAppVideo,
)
from messente_api.rest import ApiException


configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

wa_video = WhatsAppVideo(
link="<MEDIA_URL>", # URL link to the video file
)

whatsapp = WhatsApp(
sender="<SENDER_NAME>",
video=wa_video,
)

whatsapp_inner = OmnimessageMessagesInner(whatsapp)
omnimessage = Omnimessage(messages=[whatsapp_inner], to="<RECIPIENT_PHONE_NUMBER>")

try:
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception when sending an omnimessage: %s\n" % exception)

Document Message

from pprint import pprint
from messente_api import (
OmnimessageApi,
Omnimessage,
Configuration,
ApiClient,
WhatsApp,
OmnimessageMessagesInner,
WhatsAppDocument,
)
from messente_api.rest import ApiException

configuration = Configuration()
configuration.username = "YOUR_MESSENTE_API_USERNAME"
configuration.password = "YOUR_MESSENTE_API_PASSWORD"

api_instance = OmnimessageApi(ApiClient(configuration))

wa_document = WhatsAppDocument(
link="<MEDIA_URL>", # URL link to the document file
)

whatsapp = WhatsApp(
sender="<SENDER_NAME>",
document=wa_document,
)

whatsapp_inner = OmnimessageMessagesInner(whatsapp)
omnimessage = Omnimessage(messages=[whatsapp_inner], to="<RECIPIENT_PHONE_NUMBER>")

try:
response = api_instance.send_omnimessage(omnimessage)
print(
"Successfully sent Omnimessage with id: %s that consists of the following messages:"
% response.omnimessage_id
)
for message in response.messages:
pprint(message)
except ApiException as exception:
print("Exception when sending an omnimessage: %s\n" % exception)