How to add bulk email ID's using surveymonkey api v3 - surveymonkey

In case of surveymonkey api's of version v2, 'https://api.surveymonkey.net/v2/batch/send_flow' with the body containing recepients list in an array will add all the recipients emailID's to the message simply.
But in case of version v3, is there a simple method to add all the recipients on a bulk and send the emails for all those recipients? The below flow to send the message will add only one recipients emailID or else we have to do several POST calls of "POST /collectors/{id}/messages/{id}/recipients" eachtime with a new emailID. How can we add all the emailID's into the recepients list with one api call and send message to that recipients list?
POST /surveys/{id}/collectors -> POST /collectors/{id}/messages -> POST /collectors/{id}/messages/{id}/recipients -> POST /collectors/{id}/messages/{id}/send

The only way to do it is the way you suggested in V3 right now. The only thing I will add is that there is a bulk recipient endpoint.
So you would
POST /surveys/{id}/collectors
POST /collectors/{id}/messages
POST /collectors/{id}/messages/{id}/recipients/bulk
POST /collectors/{id}/messages/{id}/send
Part of the reason for preferring to split these up is for better transaction management. For example if you call send_flow and you create a collector and a message, then error trying to add recipients for whatever reason, you'll be left with lingering collector/messages. This way you can handle what happens on each error case yourself.
SurveyMonkey is considering releasing some SDKs that have functionality like that encapsulated, as well as potentially a batch request endpoint, but as of right now that is the process for sending a message in the API.
Example use of bulk recipient endpoint:
You can add a list of contacts to your message all at once like this:
POST /collectors/{id}/messages/{id}/recipients/bulk
{
"contact_ids": ["1000", "10001"]
}
You can add all contacts from a list of Contact Lists all at once like this:
POST /collectors/{id}/messages/{id}/recipients/bulk
{
"contact_list_ids": ["2000", "20001"]
}
Or you can manually add any number of contacts by email like this:
POST /collectors/{id}/messages/{id}/recipients/bulk
{
"contacts": [{
"email": "user1#example.com",
"first_name": "User 1",
"last_name": "Testing"
},{
"email": "user2#example.com",
"first_name": "User 2",
"last_name": "Testing"
}]
}
I believe you can add from all three of those methods from one request.

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

How do I get a usable email message reference id from headers to use in a Microsoft Graph query?

I am trying to use the references message ID in email headers of a forwarded email in Office 365 to then find the original email that has that message ID.
The references ID in the forwarded email's headers would show something like what's shown below. Note I'm obtaining these headers from Microsoft Graph by adding &$select=internetMessageHeaders to my query using sender/subject to find the forwarded email.
{
"name": "References",
"value": "<CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w#mail.gmail.com>"
}
However, if I take this and use it in a query like https://graph.microsoft.com/v1.0/me/messages?$filter=internetMessageId eq '<CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w#mail.gmail.com>'
I do not receive any results.
If I hunt down the original email in Microsoft Graph using sender and subject, I see the following for the internetMessageId field for the original email:
{
"name": "Message-ID",
"value": "<CAOLK2SC6s9Me05kYRqeuEHKK8DrQbXx34ScT0AzGOFFLMdRapg#mail.gmail.com>"
}
Does anyone have any ideas on what Office 365 or Microsoft Graph is doing to change CAOLK2SAEzvs=-6Rs5cTbgORNivQVK2AvMJDJT8o+ghx-XhCn7w into CAOLK2SC6s9Me05kYRqeuEHKK8DrQbXx34ScT0AzGOFFLMdRapg? It looks like some sort of encoding, but I haven't been able to reproduce it.
Ultimately I would like to be able to transform what I'm getting in the references ID header such that I can turn around and use that ID to find the original email using Microsoft Graph.
The id is a hashed value that, among other things, includes the path/folder that the message resides in. So if you, for example, move a message (say from Inbox to Archive) then you should expect the id to change.
For tracking a message, regardless of its location, you should use the internetMessageId ($select=internetMessageId) property instead.
I discovered the issue. In my test message-ID I have the characters = and +
These characters must be URL encoded to %3D and %2B before being used in the $filter query. When they are URL encoded, I am able to find the original email using MS Graph.
In Microsoft Graph v1.0 and beta, you can obtain "immutable ids" by sending an additional HTTP header in your API requests:
Prefer: IdType="ImmutableId"
I've put immutable in italics as this is the term Microsoft uses. Be aware of the following caveats, the ID will change if:
The user moves the item to an archive mailbox;
The user exports the item (to a PST, as an MSG file, etc.) and re-imports it into their mailbox;
The user creates a draft which they later send;
You can also convert existing ids to immutable ones by the following request:
POST https://graph.microsoft.com/beta/me/translateExchangeIds
{
"inputIds" :
[
"AQMkAGM2…"
],
"targetIdType" : "restImmutableEntryId",
"sourceIdType" : "restId"
}
Which will give you the response:
HTTP 200 OK
{
"#odata.context": "https://graph.microsoft.com/beta/$metadata#Collection(microsoft.graph.convertIdResult)",
"value": [
{
"targetId": "AAkALgAA...",
"sourceId": "AQMkAGM2..."
}
]
}

microsoft-graph message ID

I call my mailbox using REST calls to MSGraph:
GET https://graph.microsoft.com/v1.0/me/mailfolders/inbox/messages
As expected I receive a Json with my mails.
To play with a specific mail (move, delete,forward, ...) I saw that the API should be called like
POST me/messages/{id}/forward
I can't target the message if I provide the value of the id field that I get from the JSon. Where to find the correct {id} that I should use?
my result is like the example at https://developer.microsoft.com/en-us/graph/graph-explorer see id: field when calling GET my mails.
Thanks
The id from JSON is OK. what you missing is you have not set the post conent for move/forward.
If you use the forward API, you should set the post content like below:
{
"Comment": "FYI",
"ToRecipients": [
{
"EmailAddress": {
"Address": "XXX#XXX.onmicrosoft.com"
}
}
]
}
This is the worked forward url for me(you can implement the move/delete like this too):
https://graph.microsoft.com/v1.0/me/messages/AAMkAGNjZTcyZDJmLTkzMjYtNGQwNi05Y2UxLTc5NDk0NjEwNjJjMABGAAAAAAAUYpVLVYiKTINMO3MZR0H5BwB3NF3PTyl5QIQd59edwRO9AAAAAAEMAAB3NF3PTyl5QIQd59edwRO9AAApBI9fAAA=/forward
For information please see:
https://learn.microsoft.com/en-us/previous-versions/office/office-365-api/api/version-2.0/mail-rest-operations#ForwardDirectly

Jira Api Error when creating issue

On my website I have a contact form which when submitted, creates a new service desk ticket. It makes the following rest api call:
https://jira-housters.atlassian.net/rest/servicedeskapi/request (with appropriate Accept and Authorization request headers)
{
"serviceDeskId": "1",
"requestTypeId": "1",
"requestFieldValues": {
"summary": "Housters Contact from Justin Test (Web)",
"description": "test message"
},
"raiseOnBehalfOf": "myemail#mydomain.com"
}
Before this worked completely fine, however a few days ago it started erroring:
{"errorMessage":"Your request could not be created. Please check the fields have been correctly filled in. Please provide a valid value for field 'Raise this request on behalf of'","i18nErrorMessage":{"i18nKey":"sd.validation.request.creation.failure.required.field","parameters":["Please provide a valid value for field 'Raise this request on behalf of'"]}}
This makes no sense, as it's complaining about the raise request on behalf of field when I clearly have it specified. What gives?
raiseOnBehalfOf should have the customers accountId not email.
You can create a customer using:-
-> https://your-domain.atlassian.net/rest/servicedeskapi/customer
-> Get the accountId from the response.

Get the message ID in the survey monkey response

I am using survey monkey v3 API's to send survey emails. While sending a survey email from one collector, I am sending two different survey messages for the same recipient. However, while collecting the survey responses from survey monkey using the api "/surveys/{id}/responses/bulk", I couldn't find the messageID in it. So I how can I find which response belong to which message of the collector then? Is there a different API that I have to use?
What's the use case for tracking the specific message? You have the recipient_id, and first/last/email fields.
You can get recipient details at /collectors/{collector_id}/recipients/{recipient_id}. There's no way (as far as I can tell) to query for this other than searching your messages with /collectors/{collector_id}/messages/{message_id}/recipients
Generally speaking, when you add recipients to a message, they are shared with the collector. Which specific message was responded to is not really tracked, the tracking ID is the recipient_id with respect to the collector.
If you are interested in message stats (ex. which message gets a better response rate) you can use the message stats endpoint.
With regards to having a different message for say different products, unfortunately the message ID is not tied to a response, but two options are:
1) Use a different collector for each product (not ideal if there is a lot)
2) Use extra fields on the recipient (see example):
Example:
POST /v3/collectors/<collector_id>/messages/<message_id1>/recipients
{
"first_name": "Test",
"last_name": "Tester",
"email": "test#example.com",
"extra_fields": {
"product": "shoes"
}
}
POST /v3/collectors/<collector_id>/messages/<message_id2>/recipients
{
"first_name": "Test",
"last_name": "Tester",
"email": "test#example.com",
"extra_fields": {
"product": "shirts"
}
}
Then when you fetch the responses, you'll get that information in metadata, example:
{
"id": "<response_id>",
"recipient_id": "<recipient_id>",
"collector_id": "<collector_id>",
...
"metadata": {
"contact": {
"product": {
"type": "string",
"value": "shoes"
},
"email": {
"type": "string",
"value": "test#example.com"
}
}
}
}
One thing to watch out for is that the extra fields from the contact do not currently show up in the /responses/bulk endpoint, only individual responses/<id> endpoint. Also with extra fields you can't filter responses where product=shoes or whatnot. Those are some limitations with the current API - but hopefully it can at least be helpful for now.

Resources