Set Participant data in Open Inbound Message

Hello, I have created an open messaging integration.
When I send an open message through the API I cannot set participant data I'm using the API is through javascript SDK:
POST /api/v2/conversations/messages/{integrationId}/inbound/open/message and I am accessing it using javascript SDK.
Messages are delivered correctly and generally everything seems to work fine except setting participant data.
Below body of the request I'm sending to Genesys (using: postConversationsMessageInboundOpenMessage function):
{
"channel": {
"from": {
"email": "usermail@demo.com",
"firstName": "Guest",
"id": "usermail@demo.com",
"idType": "email",
"lastName": "User",
"nickname": "User"
},
"messageId": "8e0da971-4085-4c36-8d82-a83a6694fa75",
"time": "2024-05-01T13:01:14.462Z"
},
"metadata": {
"rating": "5"
},
"text": "provaMessaggio"
}
I expected to see raiting=5 in participant data.
Am I doing something wrong ?

Hello,

You are missing customAttributes in your metadata object.
See here for an example

    "metadata": {
        "customAttributes": {
            "rating": "5"
        }
    },

Regards,

Thank you for your promp reply: I tried adding the customAttributes object embedded in metadata:
{
"channel": {
"from": {
"email": "usermail@demo.com",
"firstName": "Guest",
"id": "usermail@demo.com",
"idType": "email",
"lastName": "User",
"nickname": "User"
},
"messageId": "e6a8bb8a-ab37-4b1f-be33-69df9b6cab11",
"time": "2024-05-02T09:31:22.733Z"
},
"metadata": {
"customAttributes": {
"rating": "5"
}
},
"text": "Test Message"
}

but I got the following error object from API endpoint:
Error sending message: {
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"contextId": "be93021b-8cac-41ef-88ee-428b47bad0db",
"details": [],
"errors": []
}
In the API Explorer the metadata object is a Key-Value pair array: do I have to use a particular syntax inside it ?

Hi @Domenico_Colella there are 2 metadata objects on the normalized message request body there. It looks like you want the one mapped to the conversation participant data. Which is the channel.metadata object. See this example Genesys Cloud Developer Center
In your JSON example, you didn't set it inside the channel object, you need to move it in there.

You can use/enable Pro Mode in the API Explorer to edit the JSON Request Body directly.

Regarding your error, as Greg mentionned, you are not following the expected structure of an Inbound Open Message. See here for an example.

Regards,

Thank you for your prompt answer but API POST /api/v2/conversations/messages/inbound/open has been deprecated and in API Explorer is written to use instead other APIs (below extract):

Send an inbound Open Message. [This API is deprecated. Instead, use 1. POST /api/v2/conversations/messages/{integrationId}/inbound/open/event, if you want to send an inbound Open Event Message 2. POST /api/v2/conversations/messages/{integrationId}/inbound/open/message, if you want to send an inbound Open Message 3. POST /api/v2/conversations/messages/{integrationId}/inbound/open/receipt, to send an inbound Open Receipt Message] In order to call this endpoint you will need OAuth token generated using OAuth client credentials authorized with at least messaging scope. This will either generate a new Conversation, or be a part of an existing conversation. See https://developer.genesys.cloud/api/digital/openmessaging/ for example usage.

I'd like to avoid using deprecated APIs, and furthermore new APIs include more features I'd like to use i.e. events, receipts... but I could not find any explanation on how participant data should be set (only doc refers to old API). Can you please help?

@Domenico_Colella you are correct that dev center page is outdated, we'll get a ticket in to modify it, thanks for bringing it up.
As for your question i'm a bit confused, the replacement POST /api/v2/conversations/messages/{integrationId}/inbound/open/message API already contains channel.metadata in the same exact form that the old deprecated api contained. What's the issue with using that? See Genesys Cloud Developer Center

Hello Greg, the format is different: if you give a look at API Explorer metadata field is defined as (Map<string, string>), so the old form "metadata": {"customAttributes":{"key":"value"}} is not valid anymore: when used the server does not understand the request and a 400 is returned. If you use the format according to API Explorer "metadata": {"key":"value"} the open message is created and handled by Genesys, but no participant data is set. Should I use a particular format in order to have metadata pushed into participant data ? Or is it a bug in the new API ? Thank for your help.

Please open a case with Customer Care if you believe it's a bug, there may be an issue there. This is the JSON format for that request body

{
  "channel": {
    "from": {
      "nickname": "",
      "id": "",
      "idType": "",
      "firstName": "",
      "lastName": "",
      "email": ""
    },
    "time": "",
    "messageId": "",
    "metadata": {
      "customAttributes": {
        "": ""
      }
    }
  },
  "text": "",
  "content": [
    {
      "attachment": {
        "id": "",
        "mediaType": "",
        "url": "",
        "mime": "",
        "text": "",
        "sha256": "",
        "filename": ""
      }
    }
  ],
  "metadata": {
    "": ""
  }
}

You need to use channel.metadata.customAttributes as we discussed above, to get the information on the conversation participant.

Hello Greg, my mistake I made confusion between the two metadata objects in the structure: the one inside channel has no fixed structure and works for setting participant data, the other outside is not working. Following your detailed example everything works fine. Thanks

just for posterity, there are 2 metadata objects on that request body, each with a little different use case

  1. channel.metadata.customAttributes - this is meant as a way for you to add attributes to the Conversation participant data. this is the one you were wanting to use all along i believe.
  2. metadata - this is meant as a way for you to "tag" a message with some info you may want. it will not be surfaced on the conversation participant data, but will be surfaced on the conversation normalized message transcripts. maybe you want to tag an external id associated with this message that Genesys Cloud will store along with your inbound open message, or something else for example

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