Which Messages are supported for subscriptions in commercetools - message

I'm currently playing with and validating commercetools api.
I want to subscribe to a certain SQS queue, in order to push messages to this queue.
However if im trying to add a subscription for a certain message type, the api returns:
{"statusCode":400,"message":"The TypeId 'DeliveryAdded' is unknown or not supported by subscriptions.","errors":[{"code":"InvalidInput","message":"The TypeId 'DeliveryAdded' is unknown or not supported by subscriptions."}]}] with root cause
For resourceTypeId, I use the above mentioned names (e.g. DeliveryAdded)
The request itself is fine.
I tried some different types, always with the same result. Is there any MessageType, which is actually supported for subscriptions ?
Edit:
POST https://api.sphere.io/some-project/subscriptions HTTP/1.1
{
"destination" : {
"type" : "SQS",
"accessKey" : "XXXXXXXX",
"accessSecret" : "XXXXXXXX",
"region" : "EU",
"queueUrl" : "https://sqs.eu-central-1.amazonaws.com/XXXXXX/YYYYYYYY"
},
"messages" : [ {
"resourceTypeId" : "CustomerCreated"
} ]

for the CustomerCreated Message the resourceTypeId should be customer
please find a list of supported resource type ids on:
http://dev.commercetools.com/http-api-projects-subscriptions.html#changesubscription

you can subscribe to the messages that are documented in the persistent Message API: http://dev.commercetools.com/http-api-projects-messages.html
So "DeliveryAdded" is a message. It could be that you have put the Message type as resourceTypeId (which is "order" in the case of the "DeliveryAdded" message since it's a message related to a change on the order resource).
Can you post your request JSON?
PS: you don't have to have the persistent Messages activated to subscribe to messages.

Related

Identifying messages posted by my app in Slack

I'm developing a Slack app that posts alert apps to channels. I want this app to check the history of a channel to find messages it has posted earlier so it can respond accordingly. For example, if there's an alert that has not yet "cleared" it will update said alert instead of posting a new message.
The challenge I'm encountering is that it's not clear how I can identify messages that my app has posted. I see that I can search a channel with conversations.history, and that gives me message events. It looks like some messages have a user property. There are also bot_message sub-type messages that have a bot_id property. However, I don't see any way to identify my app ID.
Should every app have an associated bot_id? user ID? If so, where do I get these IDs so I can filter the conversation history?
Update
I tried calling the bots.info method with no bot ID parameter hoping it would give me my bot ID, but it returned no data other than an "OK" status.
Perhaps because Slack has a long history of different APIs, I was misled. Apparently, it's possible for me to find messages my bot previously posted but not how I thought. Here were my misunderstandings and what I've found out when playing with the Slack API tester.
Using conversations.history, you can get a list of messages posted in a channel. The docs say that the history returns an array of message events, and that these have a subtype field. One of the subtypes is bot_message, so my assumption is that messages posted by my bot would have this sub-type. The docs for bot_message has a bot_id, which I don't know for my app, and username, which I don't know what it will match.
However, it turns out when I posted a test message, that the message did not show up as a bot_message; rather it appears in the history without a subtype and has properties which don't seem to match any documentation:
{
"bot_id": "B01HSBYRKUZ",
"type": "message",
"text": "Testing the Slack API; please ignore.",
"user": "U01HDNUJ5EE",
"ts": "1609878469.036400",
"team": "<omitted>",
"bot_profile": {
"id": "B01HSBYRKUZ",
"deleted": false,
"name": "my-bot-name",
"updated": 1608584973,
"app_id": "<omitted>",
"icons": {
"image_36": "...",
"image_48": "...",
"image_72": "..."
},
"team_id": "<omitted>"
}
}
So although it's risky to code against an undocumented format (or maybe I just can't find the right docs?), I can filter these messages by looking to see if there's a bot_profile.app_id that matches my app's ID, which I do know.
you may know id your bot if use context. Example: const {botUserId} = context

API key no longer working, but don't know what account it is aligned with

When calling the YouTube API, we've started getting error responses with the following message:
{
"code" : 403,
"errors" : [ {
"domain" : "usageLimits",
"message" : "Project 418176253215 has been scheduled for deletion and cannot be used for API calls. Visit https://console.developers.google.com/iam-admin/projects?pendingDeletion=true to undelete the project.",
"reason" : "accessNotConfigured",
"extendedHelp" : "https://console.developers.google.com/iam-admin/projects?pendingDeletion=true"
} ],
"message" : "Project 418176253215 has been scheduled for deletion and cannot be used for API calls. Visit https://console.developers.google.com/iam-admin/projects?pendingDeletion=true to undelete the project."
}
However, I cannot use the link provided because I can't find what account was used to create the key for the API (I've inherited the code).
Is there a way to discover what account aligns with a YouTube API key?
There is no documentation in Youtube API which states how to do this because if you own the API key, logging in the Google Dev Console under the given project name should easily display all the API keys being used.

Look a message's text from events api response

I'm using slacks events API and have setup a subscription to the reactions_added event. Now when a reaction is added to a message, slack will send me a post body with all the details of the dispatched event as described here.
The problem I'm having is that I want to get the details, specifically the text of the message that my users have reacted to so I can parse/store etc that specific message. I assumed the message would return with some type of UUID that I could then respond to the callback and get the text, however I'm find it difficult to get the specific message.
The only endpoint I see available is the channels.history, which doesn't seem to give me the granularity I'm looking for.
So the tl;dr is: How do I look up a via slacks API, a messages text sent from the events API? Give the information I have the event_ts, channel and message ts I thought would be enough. I'm using the ruby slack-api gem FWIW.
You can indeed use the method channels.history (https://api.slack.com/methods/channels.history) to retrieve message from a public channel . The reaction_added dispatched event includes the channel ID and timestamp of the original message (in the item) and the combination of channelId + timestamp should be unique.
Be careful that you use the correct timestamp though. You need to use item.ts not event_ts
Full example dispatched event from the docs:
{
"token": "z26uFbvR1xHJEdHE1OQiO6t8",
"team_id": "T061EG9RZ",
"api_app_id": "A0FFV41KK",
"event": {
"type": "reaction_added",
"user": "U061F1EUR",
"item": {
"type": "message",
"channel": "C061EG9SL",
"ts": "1464196127.000002"
},
"reaction": "slightly_smiling_face"
},
"event_ts": "1465244570.336841",
"type": "event_callback",
"authed_users": [
"U061F7AUR"
]}
So calling channels.history with these values set should work:
latest = item.ts value
oldest = item.ts value
inclusive = 1
channel = item.channel value
If you want to get messages from a private channel you need to use groups.history.
https://api.slack.com/methods/channels.history

Survey Monkey API Questions

I have a couple questions regarding the survey monkey API. First, I've noticed that the categories that can be assigned to open ended questions don't come through when pulling the details of a response. Is there a way to do this and if not, when will it be added?
Secondly, I've attempting to update the metadata field of a response, yet I'm receiving an invalid schema era.
I'm sending this in the request body:
{
"id": "4472927205",
"metadata": { "category" : "test"
}
}
This is the response I receive:
{
"error": {
"http_status_code": 400,
"message": "Invalid schema in the body provided.",
"id": "1002",
"docs": "https://developer.surveymonkey.com/api/v3/#error-codes",
"name": "Bad Request"
}
}
What is the proper schema for a request?
Categories set in the analyze section are not currently accessible through the API. There is no ETA for that at the moment.
Also the metadata shown in the responses are auto-generated based on other factors (some page logic I believe, contact information - case email collector) and are not updateable at the moment either.
See the docs also you can watch the public docs repo to be notified when the changes you'd like have been released.

O365 API filter on complex types

What is the query to get emails received from a specific sender email address?
I have tried filtering on the "Address" property of the "From" property, which is a "Recipient" complex type according to O365 Microsoft.Exchange.Services.OData.Model namespace.
OData filtering on complex types goes something like this
/Me/Inbox/Messages?$filter=From/Address eq 'email#email.com'
However, this returns the following error:
"error": {
"code": "ErrorInvalidProperty",
"message": "The property 'Address' is invalid.",
"innererror": {
"message": "The property 'Address' is invalid.",
"type": "Microsoft.Exchange.Services.OData.InvalidPropertyException",
"stacktrace": " at Microsoft.Exchange.Services.OData.SchemaExtensions.ResolveProperty(Schema schema, String propertyName)\r\n at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.GetPropertyProvider(QueryNode queryNode)\r\n at Microsoft.Exchange.Services.OData.Model.EwsFilterConverter.ConvertFilterNode(QueryNode queryNode)\r\n at Microsoft.Exchange.Services.OData.Model.EwsQueryAdapter.GetRestriction()\r\n at Microsoft.Exchange.Services.OData.Model.MessageProvider.Find(String parentFolderId, MessageQueryAdapter queryAdapter)\r\n at Microsoft.Exchange.Services.OData.Model.FindMessagesCommand.InternalExecute()\r\n at Microsoft.Exchange.Services.OData.ODataCommand`2.Execute()\r\n at Microsoft.Exchange.Services.OData.ODataTask.Execute(TimeSpan queueAndDelayTime, TimeSpan totalTime)"
}
}
I got the same error that property of complex type is invalid.
It seems that exchange service does not support complex type filtering.
You can try getting all the Messages to local storage and doing filtering.
Email address is a complex type however it is listed as filterable (https://msdn.microsoft.com/office/office365/APi/complex-types-for-mail-contacts-calendar#RESTAPIResourcesMessage) which means the following should work...
https://outlook.office365.com/api/v1.0/me/messages?$filter=From/EmailAddress/Address eq 'email#email.com'
However, I'm having trouble with this, it seems to be simply returning blank values whereas the following works...
https://outlook.office365.com/api/v1.0/me/messages?$filter=From/EmailAddress/Name eq 'Joe Bloggs'
So, there could be a fault with the API or the email address might need to be formatted differently.

Resources