Genesys Cloud - Main

 View Only

Discussion Thread View
  • 1.  Action to Send Message to Conversation Not Working

    Posted 17 days ago

    Hi there!

    I am trying to implement an Action that sends a message to a conversation but it is not working. I get this error message:

    • REST call for action execute failed. Message: Request to backend service failed. Response from web service: {"message":"User is not an active member on the conversation","code":"forbidden","status":403,"contextId":"869fbb1c-8f50-4e85-8a03-810a435d4197","details":[],"errors":[]} [65ab3a4a-0a2d-4f38-9ec9-cdae4dc0cef9]
    {
      "message": "You are not authorized to perform the requested action.",
      "code": "not.authorized",
      "status": 403,
      "messageParams": {},
      "contextId": "cd787782-0aae-4249-92d1-793422a18fdd",
      "details": [
        {
          "errorCode": "ACTION.REMOTE_ENDPOINT"
        }
      ],
      "errors": [
        {
          "message": "REST call for action execute failed. Message: Request to backend service failed. Response from web service: {\"message\":\"User is not an active member on the conversation\",\"code\":\"forbidden\",\"status\":403,\"contextId\":\"ec0ecd2f-04f9-4d9a-af2f-b510410f2b0c\",\"details\":[],\"errors\":[]} [cd787782-0aae-4249-92d1-793422a18fdd]",
          "code": "NOT_AUTHORIZED",
          "status": 403,
          "messageParams": {},
          "details": [],
          "errors": []
        }
      ]
    }

    I would appreciate any comments about anything I am overlooking, or what to try.

    Steps I Took

    I first used API Explorer to fetch the communicationId using the conversationId. I have successfullly created a Data Action to fetch the communicationID..

    I then used API Explorer to successfully send a message to an active chat conversation (version 2) using the communication ID and conversation ID. This is the endpoint I am using:

    /api/v2/conversations/chats/{conversationId}/communications/{communicationId}/messages

    I used existing Actions created by a former developer as a starting point to create the Action in question. Here is how I set it up

    Configuration Tab

    Request URL Template (POST)

     /api/v2/conversations/chats/${input.conversationId}/communications/${input.communicationId}/messages

    Request Body Template

    {
       "body": "${input.messageToSend}",
       "bodyType": "standard"
    }

    Output

    {
      "translationMap": {},
      "translationMapDefaults": {},
      "successTemplate": "${rawResult}"
    }

    Contracts Tab

    Input Contract

    {
      "title": "SendMessageToConversation",
      "description": "A request to send a message to an active conversation",
      "type": "object",
      "$schema": "http://json-schema.org/draft-04/schema#",
      "required": [
        "conversationId",
        "communicationId",
        "messageToSend"
      ],
      "properties": {
        "conversationId": {
          "description": "The conversation ID.",
          "type": "string"
        },
        "communicationId": {
          "description": "The communication ID. Session ID for chats",
          "type": "string"
        },
        "messageToSend": {
          "description": "The message to send to an existing conversation",
          "type": "string"
        }
      }
    }

    Output Contract

    {
      "title": "Response",
      "type": "object",
      "properties": {
        "message": {
          "type": "string"
        },
        "code": {
          "type": "string"
        },
        "status": {
          "type": "string"
        },
        "messageWithParams": {
          "type": "string"
        },
        "messageParams": {
          "type": "object",
          "properties": {
            "message": {
              "type": "string"
            }
          },
          "additionalProperties": true
        },
        "contextId": {
          "type": "string"
        }
      },
      "additionalProperties": true
    }


    #DigitalChannels
    #Integrations

    ------------------------------
    Waqar Mahmood
    Herbalife International of America, Inc.
    ------------------------------


  • 2.  RE: Action to Send Message to Conversation Not Working

    Posted 17 days ago

    Hello,

    You can't use a Data Action to send a message into an ongoing interaction since the API requires User Context.
    That's why you get the error "User is not an active member on the conversation" with the Data Action.

    It works in API Explorer since your logged in with you Genesys user.

    What is the use case for this?
    There might be another way to do it.



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



  • 3.  RE: Action to Send Message to Conversation Not Working

    Posted 17 days ago

    Hi there!

     

    Thanks for that response!

     

    The objective is for an agent handling a webchat to click a button on the agent script that initiates a custom action. This custom action sends messages to the conversation after defined intervals while the agent is researching information. So I would welcome any suggestions about an alternate way to achieve this objective.

     

    I naturally wondered if there is a way to obtain the user context, and do not see one. Do you know how the context is had?

     

    I am also logged into the browser I am using to create the Data Action and run the test. I am also logged in as an agent in the same browser participating in the chat.

     

    Best,

     

    Waqar






  • 4.  RE: Action to Send Message to Conversation Not Working

    Posted 17 days ago

    Hi,

    I think you would need to build a web application that you embed in the script with an iframe, as that would allow user context.

    I use that to send Agent Greetings in the chat when the agent answers an incoming chat.



    ------------------------------
    Jan Heinonen
    Contact Center Specialist
    GlobalConnect AB
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources