Hi,
I need your assistance please because I want to create whatsapp outbound messages
I have implemented the whatsapp agentless source code which is in developper tools of Genesys.
but when I debug it I get the following error message but I don't know the problem if you can assist me please
My code source:
string basePath = "/api/v2/conversations/messaging/integrations/whatsapp/81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1; // Genesys Cloud region
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken("692cf986-2a7d-4df6-9dc7-6bd7a95fff4f", "Eom0X83pVROeFQ9DB1UhZlTPXol7BfIVSVa_ycbTcwY", "https://apps.mypurecloud.ie");
string accessToken = accessTokenInfo.AccessToken;
PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
// var apiInstance = new ConversationsApi();
// var body = new SendAgentlessOutboundMessageRequest(); // SendAgentlessOutboundMessageRequest | Create agentless outbound messaging request
try
{
// Instantiate APIs
ConversationsApi conversationsApi = new ConversationsApi();
//var body = new SendAgentlessOutboundMessageRequest(); // SendAgentlessOutboundMessageRequest | Create agentless outbound messaging request
// Build request body
SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
request.FromAddress = "212XXXXXXXXXX";
request.ToAddress = "212XXXXXXXXXX";
request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
request.TextBody = "Hello, this is a test notification";
request.UseExistingActiveConversation = true;
// Call to PostConversationsMessagesAgentless function of Conversations API
SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
// Final Output
//Console.WriteLine(response.ToString());
return response.ToString();
}
catch (Exception e)
{
// Debug.Print("Exception when calling Conversations.PostConversationsMessagesAgentless: " + e.Message);
return "exception" + e.Message;
}
when the method SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request); is called the following error message is displayed
exceptionError calling PostConversationsMessagesAgentless: {"message":"No WhatsAppIntegration could be found with an id of {id}","code":"not.found","status":404,"messageWithParams":"No {type} could be found with an id of {id}","messageParams":{"id":"","type":"WhatsAppIntegration"},"contextId":"cece967f-cef6-414f-8ca7-d2fcfe099978","details":[],"errors":[]}
This seems to be indicating that there isn't a whatsapp integration for a blank ID, which makes sense by itself. However, there is no way for you to specify an ID in that request so this error is nonsensical in context. Please open a case with Genesys Cloud Care to investigate as this appears to be a bug.
Thank you Tim for your help,
as suggested I checked with Genesys Cloud Care , who asked me to set integration id in fromaddress, which I did but I got another error message
My Code source string basePath = "/api/v2/conversations/messaging/integrations/whatsapp/81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1; // Genesys Cloud region
// apiClientPost.setBasePath(region);
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken("692cf986-2a7d-4df6-9dc7-6bd7a95fff4f", "Eom0X83pVROeFQ9DB1UhZlTPXol7BfIVSVa_ycbTcwY", "https://apps.mypurecloud.ie");
string accessToken = accessTokenInfo.AccessToken;
PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
try
{
// Instantiate APIs
ConversationsApi conversationsApi = new ConversationsApi();
//var body = new SendAgentlessOutboundMessageRequest(); // SendAgentlessOutboundMessageRequest | Create agentless outbound messaging request
// Build request body
SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
request.FromAddress = "81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
request.ToAddress = "212XXXXXXXXXX";
request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
request.TextBody = "Hello, this is a test notification";
request.UseExistingActiveConversation = false;
// Call to PostConversationsMessagesAgentless function of Conversations API
SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
// Final Output
//Console.WriteLine(response.ToString());
return response.ToString();
}
catch (Exception e)
{
// Debug.Print("Exception when calling Conversations.PostConversationsMessagesAgentless: " + e.Message);
return "exception" + e.Message;
}
Error Message :
exceptionError calling PostConversationsMessagesAgentless: {"message":"Bad request: Message text cannot be sent with messengerType ","code":"bad.request","status":400,"messageWithParams":"Bad request: {details}","messageParams":{"details":"Message text cannot be sent with messengerType "},"contextId":"76d868ee-5ddd-4bc7-847f-0e9f03cb6ed8","details":[],"errors":[]}
Hi Tim
Thank you for your update,
Yes i tried it ,
I removed this line from the code :
request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
fromAddress
(string required) The messaging address of the sender of the message. For an SMS messenger type, this must be a currently provisioned SMS phone number. For a WhatsApp messenger type use the provisioned WhatsApp integration’s ID.
toAddress
(string required) The messaging address of the recipient of the message. For an SMS messenger type, the phone number address must be in E.164 format. E.g. +13175555555 or +34234234234.
toAddressMessengerType
(string required) The recipient messaging address messenger type.Valid values: sms, whatsapp, open.
messagingTemplate
(MessagingTemplateRequest) The messaging template to use in the case of WhatsApp messenger type. This field is required when using WhatsApp messenger type.
Hi @Greg_Boston
Thank you for your answer,
how can I create a messagingTemplate please?
can you send me a link to the documentation or an example to follow on the messagingTemplate creation part please?
I created a predefined message of type "message template"
I filled in the fields as follows:
id namespace = TESTTEMPLATE
Name of the template = TESTTEMPLATE
and i changed my code source like below:
string basePath = "/api/v2/conversations/messaging/integrations/whatsapp/81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
// var apiClientPost = new ApiClient(basePath);
PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1; // Genesys Cloud region
// apiClientPost.setBasePath(region);
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken("692cf986-2a7d-4df6-9dc7-6bd7a95fff4f", "Eom0X83pVROeFQ9DB1UhZlTPXol7BfIVSVa_ycbTcwY", "https://apps.mypurecloud.ie");
string accessToken = accessTokenInfo.AccessToken;
PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
try
{
// Instantiate APIs
ConversationsApi conversationsApi = new ConversationsApi();
// Build request body
SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
request.FromAddress = "81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
request.ToAddress = "212XXXXXXXXXX";
request.MessagingTemplate = new MessagingTemplateRequest();
MessagingTemplateRequest req = new MessagingTemplateRequest();
req.ResponseId = "TESTTEMPLATE";
request.MessagingTemplate.ResponseId = req.ResponseId.ToString();
request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
request.TextBody = "Hello, this is a test notification";
request.UseExistingActiveConversation = false;
// Call to PostConversationsMessagesAgentless function of Conversations API
SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
// Final Output
//Console.WriteLine(response.ToString());
return response.ToString();
}
catch (Exception e)
{
// Debug.Print("Exception when calling Conversations.PostConversationsMessagesAgentless: " + e.Message);
return "exception" + e.Message;
}
This message error is displayed:
exceptionError calling PostConversationsMessagesAgentless: {"message":"Bad request: Message text cannot be sent with messengerType ","code":"bad.request","status":400,"messageWithParams":"Bad request: {details}","messageParams":{"details":"Message text cannot be sent with messengerType "},"contextId":"aaf04559-28df-42fb-bcc4-58432fab5d37","details":[],"errors":[]}
@Riko80 What that error is trying to explain, is that the messagingTemplate is the message you are sending to the WA user here. There should be no request.TextBody = in your code. Because you can't send agentless outbound text for WA, due to the 24 hour rule described on the resource center documentation pages. You can only send the messagingTemplate with the message you want in it for the agentless endpoint. That is the only supported way.
Hi @Greg_Boston
Thank you for your help,
I removed the request.textBody line from my source code
I created a new template and named it test24h
I filled in the fields as follows:
id namespace = test24h
Name of the template = test24h
Below my code source :
string basePath = "/api/v2/conversations/messaging/integrations/whatsapp/81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
PureCloudRegionHosts region = PureCloudRegionHosts.eu_west_1;
PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.setBasePath(region);
var accessTokenInfo = PureCloudPlatform.Client.V2.Client.Configuration.Default.ApiClient.PostToken("692cf986-2a7d-4df6-9dc7-6bd7a95fff4f", "Eom0X83pVROeFQ9DB1UhZlTPXol7BfIVSVa_ycbTcwY", "https://apps.mypurecloud.ie");
string accessToken = accessTokenInfo.AccessToken;
PureCloudPlatform.Client.V2.Client.Configuration.Default.AccessToken = accessToken;
try
{
// Instantiate APIs
ConversationsApi conversationsApi = new ConversationsApi();
// Build request body
SendAgentlessOutboundMessageRequest request = new SendAgentlessOutboundMessageRequest();
request.FromAddress = "81ff9d2a-a865-48b2-bb3e-7c4fbe0a14b0";
request.ToAddress = "212xxxxxxxxxx";
request.MessagingTemplate = new MessagingTemplateRequest();
MessagingTemplateRequest req = new MessagingTemplateRequest();
req.ResponseId = "test24h";
request.MessagingTemplate.ResponseId = req.ResponseId.ToString();
request.ToAddressMessengerType = SendAgentlessOutboundMessageRequest.ToAddressMessengerTypeEnum.Whatsapp;
request.UseExistingActiveConversation = false;
// Call to PostConversationsMessagesAgentless function of Conversations API
SendAgentlessOutboundMessageResponse response = conversationsApi.PostConversationsMessagesAgentless(request);
// Final Output
return response.ToString();
}
catch (Exception e)
{
return "exception" + e.Message;
}
This new message error is displayed :
exceptionError calling PostConversationsMessagesAgentless: {"message":"No Response could be found with an id of test24h","code":"not.found","status":404,"messageWithParams":"No {type} could be found with an id of {id}","messageParams":{"id":"test24h","type":"Response"},"contextId":"c17de394-b9e5-432f-b420-473deb0b2c33","details":[],"errors":[]}
Regards
@Riko80 it appears you didn't use a ResponseManagement Id in the request. Please look at the documentation and adjust your code to supply the correct values for your use case. You can use GET api/v2/responsemanagement/libraries?messagingTemplateFilter=whatsapp api to help you there likely
messagingTemplate
(MessagingTemplateRequest) The messaging template to use in the case of WhatsApp messenger type. This field is required when using WhatsApp messenger type.
responseId
(string) A Response Management response identifier for a messaging template defined response.
parameters
(TemplateParameter[]) A list of Response Management response substitutions for the response's messaging template.
id
(string) Response substitution identifier.
value
(string) Response substitution value.
Hi @Greg_Boston,
Thank you for your update,
I can't access to api/v2/responsemanagement/libraries?messagingTemplateFilter=whatsapp
Can you provide me documentation please for ResponseManagement Id
Thank you very much,
Regards