08-17-2023 01:06 PM - edited 08-17-2023 02:35 PM
Hey,
I'm trying to create a service app for my organization to list & read messages from users. When using the API in the developer portal the call to "https://webexapis.com/v1/messages?roomId=ID" returns a list of messages for that room. But the same call in service app returns a "message not found" result.
Solved! Go to Solution.
08-18-2023 07:44 AM
You can only list all messages for spaces that you are in. Service Apps are their own machine account and don't act on behalf of the user that authorizes it like an integration does so unless you add the SA to the space it won't be able to list all messages. With the compliance scope you can only get specific message details. The CO role is meant to be used to poll the /events API and then get details of specific messages, memberships, etc...
You can add the SA to a space using the /memberships API but you'll need to get the personId for the SA first, which can be obtained by querying /people/me with the SA token as long as it has the spark:people_read scope. Once the SA is in the space then it would be able to list all messages with the user level scope spark:messages_read.
08-18-2023 07:38 AM
Thanks. Please note, that even with a Compliance Officer, you will not be able to list all messages in a space. But you will be able to read individual messages. If you use the Events API https://developer.webex.com/docs/api/v1/events/list-events to get a message ID, can you then read that message using https://developer.webex.com/docs/api/v1/messages/get-message-details ?
08-18-2023 03:54 AM
@alexvelt does the Service App has Compliance Officer scopes, namely spark-compliance:messages_read and was the SA approved by a Compliance Officer in Control Hub?
08-18-2023 06:58 AM
Yes, The Service App has "spark-compliance:messages_read" and the Control Hub role used to approve has "advanced troubleshooting, Compliance officer, Full admin, User, Webex site admin, atlasRoles.WXC_Cdr_Rest_ReadOrgRole"
08-18-2023 07:44 AM
You can only list all messages for spaces that you are in. Service Apps are their own machine account and don't act on behalf of the user that authorizes it like an integration does so unless you add the SA to the space it won't be able to list all messages. With the compliance scope you can only get specific message details. The CO role is meant to be used to poll the /events API and then get details of specific messages, memberships, etc...
You can add the SA to a space using the /memberships API but you'll need to get the personId for the SA first, which can be obtained by querying /people/me with the SA token as long as it has the spark:people_read scope. Once the SA is in the space then it would be able to list all messages with the user level scope spark:messages_read.
08-22-2023 06:07 PM
Hey Jeff,
Just to follow up on this is there a way to add the service app to a 1:1 / direct conversation. If not is there any way to read a 1:1 conversation with the compliance officer role?
08-23-2023 05:41 AM
A 1:1 space can only have two participants so there would be no way to add another user or SA to a existing 1:1 space to be able to read all messages in the space. With the CO role you'd need to get all of the message events from the /events API. The message events do contain the message content so there would be no need to make additional queries. You can just pull all message events into a database or something and then filter them on your end by roomId to see all messages in a 1:1 space.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide