Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Current »

IMChannel

IMChannel is involved only for the interaction with the Infobip WhatsApp channel. It does not require connecting to MongoDB to collect settings because they are provided by ctlive itself. But it requires connecting to Redis, which it uses as an in-memory DB to store info.

You have to check IMChannel logs if a WhatsApp message is not generating a contact, or if outbound messages are not delivered. Or, in general, any other issues that involve single WhatsApp messages.

Format

Logs report the function name in square brackets and after that a specific message according to the function

imchannel  | [IMCHANNEL] [onMessage] Message received {"results":[{"from":"351927482662","to":"447860099299","integrationType":"WHATSAPP","receivedAt":"2025-02-27T15:44:57.000+0000","messageId":"wamid.HBgMMzUxOTI3NDgyNjYyFQIAEhggNEVERTc4NzZBNzJFNTYyRTJFQjZDQzQ3OTdDRTA0RjIA",
"pairedMessageId":null,"callbackData":null,"message":{"text":"Oh well","type":"TEXT"},"contact":{"name":"Teresa Gomes"},"price":{"pricePerMessage":0,"currency":"SEK"}}],"messageCount":1,"pendingMessageCount":0}

Use cases

Incoming message

An incoming WhatsApp message from the customer is reported with the onMessage tag and the following structure

imchannel  | [IMCHANNEL] [onMessage] Message received {"results":[{"from":"39123456789","to":"44123456789","integrationType":"WHATSAPP","receivedAt":"2025-02-27T15:44:57.000+0000","messageId":"wamid.HBgMMzUxOTI3NDgyNjYyFQIAEhggNEVERTc4NzZBNzJFNTYyRTJFQjZDQzQ3OTdDRTA0RjIA",
"pairedMessageId":null,"callbackData":null,"message":{"text":"Oh well","type":"TEXT"},"contact":{"name":"Username1"},"price":{"pricePerMessage":0,"currency":"SEK"}}],"messageCount":1,"pendingMessageCount":0}

It dumps the full log message coming from the provider, including the from and to number, the timestamp, and the messageId useful to check it directly on the Infobip portal in the history section.

Outbound message

Search for the sendMessage tag to search for the message payload sent to Infobip

imchannel  | [IMCHANNEL] [sendMessage] request to [https://xxxx.api.infobip.com/omni/1/advanced] Data [{"scenarioKey":"AAAAAAAAAAAABC63903B684B3E46C5DD869","destinations":[{"to":{"phoneNumber":"39123456789"}}],"whatsApp":{"text":"Service Message - Chat Closed Success."}}] with api key header

It dumps the full message containing the URL (different for each Infobip account), scenarioKey (different for each WhatsApp number), and the WhatsApp message to send.

Response

The Infobip response is logged in the following way, reporting if the message request has been accepted.

imchannel  | [IMCHANNEL] [sendMessage] response of [https://xxxxxx.api.infobip.com/omni/1/advanced]: {"messages":[{"to":{"phoneNumber":"39123456789"},"status":{"groupId":1,"groupName":"PENDING","id":7,"name":"PENDING_ENROUTE","description":"Message sent to next instance"},"messageId":"6920cb18-8b18-4172-9de7-514e2aac9ef1"}]}

Outbound multimedia messages

Images, documents, and audio files to be sent to the customers are delivered in a two-step way.

First step: a message containing only metadata and a URL to retrieve the content, with the response coming from Infobip

imchannel  | [IMCHANNEL] [sendWhatsAppImageMessage] request to [https://xxxx.api.infobip.com/omni/1/advanced] Data [{"scenarioKey":"a8b1bf3c-492e-4d5e-a467-62450f3469d8","destinations":[{"to":{"phoneNumber":"39123456789"}}],"whatsApp":{"text":"NFO_resized.jpg","imageUrl":"htt
ps://siotunnel.ei.eilabonline.biz/tenantname/imchannel/getImageMessage/bb8b8717-5b71-45a7-be04-af9cb746661b"}}] with api key header
imchannel  | [IMCHANNEL] [sendWhatsAppImageMessage] response of [https://6jyz65.api.infobip.com/omni/1/advanced]: {"messages":[{"to":{"phoneNumber":"351927482662"},"status":{"groupId":1,"groupName":"PENDING","id":7,"name":"PENDING_ENROUTE","description":"Message sent to next
 instance"},"messageId":"a8b1bf3c-492e-4d5e-a467-62450f3469d8"}]}

Second step: Infobip retrieves the content of the multimedia file. The ID is the one specified in the URL of the previous message (https://siotunnel.ei.eilabonline.biz/tenantname/imchannel/getImageMessage/bb8b8717-5b71-45a7-be04-af9cb746661b)

Infobip requests always the same message twice, the first as HEAD method and the second as GET.

imchannel  | [IMCHANNEL] [onGetImageMessage] Request received for ID [bb8b8717-5b71-45a7-be04-af9cb746661b]
imchannel  | [IMCHANNEL] [onGetImageMessage] [REDIS] Get message with key [IMChannel:MultimediaMessage:bb8b8717-5b71-45a7-be04-af9cb746661b]
imchannel  | [IMCHANNEL] [onGetImageMessage] Set expire for key [IMChannel:MultimediaMessage:bb8b8717-5b71-45a7-be04-af9cb746661b] 1
imchannel  | [IMCHANNEL] [onGetImageMessage] Request received for ID [bb8b8717-5b71-45a7-be04-af9cb746661b]
imchannel  | [IMCHANNEL] [onGetImageMessage] [REDIS] Get message with key [IMChannel:MultimediaMessage:bb8b8717-5b71-45a7-be04-af9cb746661b]
imchannel  | [IMCHANNEL] [onGetImageMessage] Set expire for key [IMChannel:MultimediaMessage:bb8b8717-5b71-45a7-be04-af9cb746661b] 1
  • No labels