akag1 | 2020-11-05 18:54:50 UTC | #1
Requirements Sending SMS from the back-end and reply on the SMS should be routed to the respective queue if configured
Steps Taken
- Created OAuth object using websiteURL#/admin/integrations/oauth with grant type as "Client Credentials" and Role as "Mater Admin". Got clientid and clientsecret in return
- Used the above details about the client to create an Http client in the back-end, which is the tested code as it used earlier for other operations such as "UpdateMessagesParticipant"
- Now we have used the client to make a post HTTP request to create a messaging conversation object based on the following documentation api/rest/v2/conversations/#post-api-v2-conversations-messages
- We are getting 400 bad requests, thus I believe that there is no issue with the authorization. But then there is some issue with the request:
- req := types.CreateMessageConversationRequest{
QueueID: "**********", PhoneNumber: "+19***", MessageType: "sms", UseExistingConversation: true, }
- But the request succeed on API explorer developer.mypurecloud.com/developer-tools/#/api-explorer after adding myself as memeber on the queue using admin/admin/organization/queuesV2/<queueid>
- Now I don't have option to add the Client Credential to the queue. Thus I suspect the error might be because of non availability of the Client Credential as member of the queue
- Expected behavior
- Able to create messaging conversation and send the SMS using the conversation object created. Currently plan is to send SMS using developer.mypurecloud.com/api/rest/v2/conversations/#post-api-v2-conversations-messages--conversationId--communications--communicationId--messages
Open Question
- Is it possible from the back-end(Go) to send the SMS?
- Is there anything we are missing in the above steps?
- How to add Client Credentials as a member of the queue?
- How to get the communicationid and conversationid once the conversation is created?
We have tried the following API as suggested in the earlier reply "/api/v2/conversations/messages/agentless". Still we are getting the same error which is 400 Bad Request. The exact request provided by us is: { "fromAddress": "+1<Valid-Phone-Number>", "toAddress": "+1<Valid-Phone-Number>", "toAddressMessengerType": "sms", "textBody": "Please ignore - This is for testing - Just Acknowledge by replying on slack" }
anon90596342 | 2020-11-05 22:27:58 UTC | #2
Hi,
Thanks for the question. You mentioned the 400 Bad Request error. Can you find out what is the error message or error body? Normally it should indicate what went wrong.
Thanks
Greg_Boston | 2020-11-06 00:55:05 UTC | #3
Hello, You can generate an outbound sms to a customer a couple of different ways.
- Agentless outbound sms - See https://developer.mypurecloud.com/api/tutorials/agentless-sms-notifications/?language=java&step=1 for an example. Keep in mind this is really meant for a 3rd party system, not an agent/user. So it uses an Oauth client token, not a user token. In this case you will specify your
from number (your Genesys Cloud sms purchased number) and your to number (the customer you want to contact) - On behalf of queue - If you are expecting an agent/user to send an outbound sms message then you can use Outbound SMS on behalf of queue. In this case the
from number will be the assigned sms purchased number that you have set on the queue you specify (See https://developer.mypurecloud.com/api/rest/v2/routing/#put-api-v2-routing-queues--queueId- the outboundMessagingAddresses field there, similar to above you will then specify the to number (the customer you want to contact). For making that request see https://developer.mypurecloud.com/api/rest/v2/conversations/#post-api-v2-conversations-messages This would use a typical user token, this one can also be called from our Genesys Cloud UI.
A couple things from your message.
req := types.CreateMessageConversationRequest{
QueueID: "*********************",
PhoneNumber: "+19",
MessageType: "sms",
UseExistingConversation: true,
}
Notice that last , comma. that makes the JSON not valid. You would need to remove that comma
"How to get the communicationid and conversationid once the conversation is created?" In both the agentless or the on behalf of queue request, the response will contain a Conversation/ConversationId. You can use https://developer.mypurecloud.com/api/rest/v2/conversations/#get-api-v2-conversations-messages--conversationId- to GET that conversation by it's Id and get all the info you should need from it
Hope this helps.
system | 2020-12-07 00:55:05 UTC | #4
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.
This post was migrated from the old Developer Forum.
ref: 9253