I have an 200 ok but i don't receive message whatsapp

Hi,
I want to create an api to send whatsapp agentless messages
on Visual studio I developed this code, I have no error everything works correctly and I receive 200 OK on the level of the response ( SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
but the problem is that I do not receive whatsapp messages on my phone if you can tell me the source of the problem please
below my code :
var clientId = "My clientId";
var clientSecret = "MYsecretClient";
PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1;
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken(clientId, clientSecret, "https://apps.mypurecloud.ie", "");

        try
        {

            // Instantiate APIs
            ConversationsApi conversationsApi = new ConversationsApi();                
            // Build request body
            SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
            request.FromAddress = "MYID";               

            // Numéro de téléphone du destinataire au format international
            request.ToAddress = "06XXXXXXXX";

            // Contenu du message
            request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
            request.MessagingTemplate = new MessagingTemplateRequest();
            MessagingTemplateRequest req = new MessagingTemplateRequest();

            req.ResponseId = "56f70586-1c28-4b04-af5c-fd7a04913589";
            request.MessagingTemplate.ResponseId = req.ResponseId;
            TemplateParameter tplparam = new TemplateParameter();
            tplparam.Id = "56f70586-1c28-4b04-af5c-fd7a04913589";
            tplparam.Value = "Test_Reply";
            List<TemplateParameter> ListParam = new List<TemplateParameter>();
            ListParam.Add(tplparam);
            req.Parameters = ListParam;
            request.MessagingTemplate.Parameters = req.Parameters;

            //request.TextBody = "Hello, this is a test notification";
            request.UseExistingActiveConversation = true;

            // Call to PostConversationsMessagesAgentless function of Conversations API
            SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
           
        }
        catch (Exception e)
        {
            //Debug.Print("Exception when calling Conversations.PostConversationsMessagesAgentless: " + e.Message);

            return "exception" + e.Message;
        }

Regards

Hi,
Any update please?
Regards

Hi,
Any update please? it 's very pressing matter please
Regards

Hi @Ericblanc,
That Api, like all message sending Apis for digital messaging, is not a synchronous request. It's async, so that means there are a few steps involved with sending a message to the end platform. In this case the 1st step is to get an accepted request when calling the api (202 response), which is appears you have gotten. In that response you should have received ...
id - this is the messageId for you request
conversationId - this is the conversationId your message will be on
selfUri - how you can poll and GET the status of the message, as it's async sending process is handled

When you poll to get the status of the message you may see the message transition from some of these statuses (queued, sent, delivery-success OR delivery-failed). There can also be an errorInfo field present for any delivery failure, that could also help you identify any issues you may have.

Hope this helps

Hi @Greg_Boston,
Thank you for your update,
I sent the message 2 days ago and I still haven't received anything.
what should i do now?
should i add more development in my code?
Regards

@Ericblanc what do you mean you "haven't received anything"? In your example, what is your sent messageId, status field now, when you GET that message through the public api request? If you mean the status on the message was delivery-success, however the end WA customer you were sending to, didn't actually receive the message. You may need to open a request with Genesys Cloud Customer Care to help investigate more.

@Greg_Boston

here is the answer I receive in visual studio, I do not see any status, what are the next steps?

class SendAgentlessOutboundMessageResponse { Id: df098bc0bed92682daeaf35f3d005b85 ConversationId: b34b7a46-557b-4f8a-aaa8-c57c2db2239e FromAddress: 94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0 ToAddress: 06xxxxxxxx MessengerType: Whatsapp TextBody: MessagingTemplate: class MessagingTemplateRequest { ResponseId: 56f70586-1c28-4b04-af5c-fd7a04914052 Parameters: System.Collections.Generic.List`1[PureCloudPlatform.Client.V2.Model.TemplateParameter] } UseExistingActiveConversation: False Timestamp: 24/04/2023 08:56:56 SelfUri: /api/v2/conversations/messages/b34b7a46-557b-4f8a-aaa8-c57c2db2239e/messages/df098bc0bed92682daeaf35f3d005b85 User: }

Regards

@Ericblanc Please have a look at my first reply. In that reply i tried to explain how you can poll for the message status. using the SelfUri you have there in your response. Or you could use one of these APIs for similar results
GET conversation message OR GET message by id
Since message sending is an async process it can fail in various possible ways, even within the 3rd party (Whatsapp here). It's on you, to poll and wait for the status to understand what happened with that message.

1 Like

Hi @Greg_Boston

I have just done the test, and I have a status "delivryfailed" below the response received

class MessageData { Id: 415b279ad574902bfac75c09f755b831 Name: ProviderMessageId: 125b279ad574902bfac75c09f755b831 Timestamp: 24/04/2023 19:10:24 FromAddress: 94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0 ToAddress: 06XXXXXXXX Direction: Outbound MessengerType: Whatsapp TextBody: Status: Deliveryfailed Media: Stickers: NormalizedMessage: class ConversationNormalizedMessage { Id: 415b279ad574902bfac75c09f755b831 Channel: class ConversationMessagingChannel { Id: 94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0 Platform: Whatsapp MessageId: To: class ConversationMessagingToRecipient { Nickname: Id: 06XXXXXXXX IdType: Image: FirstName: LastName: Email: AdditionalIds: } From: class ConversationMessagingFromRecipient { Nickname: Org name Id: 94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0 IdType: Opaque Image: FirstName: LastName: Email: AdditionalIds: } Time: 24/04/2023 19:10:24 DateModified: DateDeleted: } Type: Structured Text: Bonjour , Merci d'avoir contacté , Un de nos agents prendra contact avec vous les plus brefs délais Content: System.Collections.Generic.List1[PureCloudPlatform.Client.V2.Model.ConversationMessageContent] Events: Status: Reasons: OriginatingEntity: Bot IsFinalReceipt: Direction: Outbound Metadata: ByoSmsIntegrationId: } NormalizedReceipts: System.Collections.Generic.List1[PureCloudPlatform.Client.V2.Model.ConversationNormalizedMessage] CreatedBy: class User { Id: 55cdb458-7aea-42aa-b575-9e83f40b3104 Name: Division: Chat: Department: Email: PrimaryContactInfo: Addresses: State: Title: Username: Manager: Images: Version: Certifications: Biography: EmployerInfo: RoutingStatus: Presence: IntegrationPresence: ConversationSummary: OutOfOffice: Geolocation: Station: Authorization: ProfileSkills: Locations: Groups: Team: Skills: Languages: AcdAutoAnswer: LanguagePreference: LastTokenIssued: DateLastLogin: SelfUri: /api/v2/users/55cdb458-7aea-42aa-b575-9e83f40b3104 } ConversationId: b34b7a46-557b-4f8a-aaa8-c57c2db2239e SelfUri: /api/v2/conversations/messages/b34b7a46-557b-4f8a-aaa8-c57c2db2239e/messages/415b279ad574902bfac75c09f755b831 }

Regards

@Ericblanc Unfortunately I am having a hard time deciphering your post there, using what appears to be SDK classes you have copy/pasted in the chat. It would be much easier to look at the raw JSON response outside the SDK likely.
If you use the Making Api explorer requests section here it explains how you can make those API requests in the web browser app for the API Explorer. Which will give you raw JSON responses that are easier to understand. The request you want to make is something like this one Get conversation message by Id Or you could use a tool like Postman to help as well.
In this JSON response we should be able to see a normalizedReceipts object. that should contain a reasons field with why this message failed.

Hi @Greg_Boston,

I'm sorry for the code from before, below the code transformed into json,
{ "direction": "outbound", "messengerType": "whatsapp", "status": "delivery-failed", "id": "415b279ad574902bfac75c09f755b831", "providerMessageId": "415b279ad574902bfac75c09f755b831", "timestamp": "2023-04-24T19:10:24.722Z", "fromAddress": "94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0", "toAddress": "06XXXXXXXX", "normalizedMessage": { "type": "Structured", "originatingEntity": "Bot", "direction": "Outbound", "id": "415b279ad574902bfac75c09f755b831", "channel": { "platform": "Whatsapp", "id": "94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0", "to": { "id": "06XXXXXXXX" }, "from": { "idType": "Opaque", "nickname": "Org Name", "id": "94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0" }, "time": "2023-04-24T19:10:24.722Z" }, "text": "Bonjour , \nMerci d'avoir contacté , \nUn de nos agents prendra contact avec vous les plus brefs délais \n\n", "content": [ { "contentType": "Notification", "template": { "id": "485afc19_c621_4f90_b97c_5ea5f7f4032b@auto_replay", "language": "fr", "body": { "text": "Bonjour , \nMerci d'avoir contacté , \nUn de nos agents prendra contact avec vous les plus brefs délais \n\n" } } } ] }, "normalizedReceipts": [ { "type": "Receipt", "status": "Failed", "direction": "Outbound", "id": "415b279ad574902bfac75c09f755b831", "channel": { "platform": "Whatsapp", "id": "81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0", "to": { "id": "06XXXXXXXX" }, "from": { "idType": "Opaque", "nickname": "org name", "id": "94ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0" }, "time": "2023-04-24T19:10:25.114Z" }, "reasons": [ { "code": "InvalidMessageStructure", "message": "Destination is invalid" } ], "isFinalReceipt": true } ], "createdBy": { "id": "55cdb458-7aea-42aa-b575-9e83f40b3104", "selfUri": "/api/v2/users/55cdb458-7aea-42aa-b575-9e83f40b3104" }, "conversationId": "b34b7a46-557b-4f8a-aaa8-c57c2db2239e", "selfUri": "/api/v2/conversations/messages/b34b7a46-557b-4f8a-aaa8-c57c2db2239e/messages/415b279ad574902bfac75c09f755b831" }

This is the issue. Whatsapp is saying that destination is invalid. You would need to look at the toAddress you supplied and make sure it's the correct WA end user id. you can review Agentless WhatsApp notifications - Genesys Cloud Resource Center for more info.
One of the easiest ways to be sure of this, is to have your WA user message the Genesys Cloud WA integration's number first (so an inbound message, not outbound notification). Then GET the conversation, and validate the from object in the normalizedMessage like your example JSON you posted last (see Recipient identifiers). Since we know that is the correct from account. you can take that and use the same number in your Agentless request in the toAddress field

Hello @Ericblanc,

I think that the issue you are facing is because you need to add your country code in the phone number : toAdress.

So instead of using : 06XXXXX try with 336XXXXXXX. Do not use +336XXXXX or it will fail.

Hope it helps.

Regards,

Nathan.

Hi @ Nathan_Tossens
Thank you for your update,
i tried with 336xxx and it works
Thanks

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.