Legacy Dev Forum Posts

 View Only

Sign Up

Send message to webmessenger using POST message API from Architect flow

  • 1.  Send message to webmessenger using POST message API from Architect flow

    Posted 06-05-2025 18:23

    WojciechPiatkiewicz | 2022-07-26 13:16:58 UTC | #1

    Hello,

    What I am trying to do, is to send post-interaction message with URL to custom survey to client within webmessage conversation. I am able to do it using my account logged in within developer tools, and launching API /api/v2/conversations/messages/{conversationId}/communications/{communicationId}/messages, that API posts message to existing conversation.

    However, I am trying to configure Action in Integrations for the same, so I can post that message from Architect flow level (Post Interaction survey invite flow will be used for that, API is supposed to run from there).

    Where I'm getting into trouble is, that I cannot properly authorize that API so it can post anything to existing webmessage conversation. Here is the configuration, URL : /api/v2/conversations/messages/${input.conversationId}/communications/${input.communicationId}/messages { "requestUrlTemplate": "/api/v2/conversations/messages/${input.conversationId}/communications/${input.communicationId}/messages", "requestType": "POST", "headers": { "Content-Type": "application/json", "Host": "api.mypurecloud.com", "Authorization": "Bearer <credentials.access_token>" }, "requestTemplate": "{\"textBody\":\"test\"}" }

    But API fails all the time with authorization error

    { "message": "No authentication bearer token specified in authorization header.", "code": "authentication.required", "status": 401, "messageParams": {}, "contextId": "06fc1f32-c422-40b6-8ed8-16e40fa0b5a3", "details": [ { "errorCode": "ACTION.REMOTEENDPOINT" } ], "errors": [ { "message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: {\"message\":\"Invalid login credentials.\",\"code\":\"bad.credentials\",\"status\":401,\"contextId\":\"46c286a3-21df-4fa3-9e79-4cbf6d036b88\",\"details\":[],\"errors\":[]} [06fc1f32-c422-40b6-8ed8-16e40fa0b5a3]", "code": "AUTHENTICATIONREQUIRED", "status": 401, "messageParams": {}, "details": [], "errors": [] } ] }

    OAuth client is setup, added to integration, have correct clientID and secret, and integration have super admin permissions, so message.create and webmessage.create are added (it has full access to all webmessage areas)


    John_Carnell | 2022-07-26 13:31:57 UTC | #2

    Hi Wojciech,

    Almost all of our conversation APIs that interact with a conversation requires a user context in order to participate in them. So client credentials will not work in an architect flow situation because there are no client credentials. That's why it works in API explorer and not in your architect flow.

    You could use our APIs to send an outbound SMS message (but it would not appear as part of the conversation.). We have a blueprint that demonstrates how to send surveys via an SMS (the blueprint is still in draft form, but the code is available) that might be useful. It can be found here.

    I am also going to pass this to a few solution consultants I know and see if they have any thoughts.

    Thanks, John Carnell Manager, Developer Engagement


    system | 2022-08-26 13:32:45 UTC | #3

    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: 15678