Twilio Taskrouter - How to add information to custom tasks? - twilio

I'm working with Twilio programmable video and I'd like to integrate it with TaskRouter.
Currently I can create custom tasks with a POST request to:
https://taskrouter.twilio.com/v1/Workspaces/{WorkspaceSID}/Tasks/
Yet regardless of what I put into the request body, the task shows up as "Anonymous Task, Reserved".
Is this an issue of formatting? I'd ideally like it to say something along the lines of "Incoming video request" with the customer name in the task-bar similar to how chat tasks look.
Here's the dummy data I tried passing in to no avail. I've tried a few different ways:
{
"attributes": {
"type": "video",
"contact": "+17777777777",
"customer-value": "gold",
"task-reason": "support",
"callSid": "CA42ed11...",
"name": "Joe",
"customer_name": "Joe"
}
"name": "Joe",
"customer_name": "Joe"
}
None of this data is passed through to the task. Any help would be appreciated.

Related

Logic apps- Post a choice of options as the flow bot to group chat

I can see that logic app has Microsoft teams "Post a choice options as the Flow bot to a user" action. However, I would like something where I can present options to a group chat or channel. The reason for not sending multiple individual messages are because I would like only 1 person to response in first come first serve kind of way.
Is there any way I can achieve this?
I can see that logic app has Microsoft teams "Post a choice option as the Flow bot to a user
Yes, you can use Post a choice of options as the flow bot to a user connector in logic Apps to present options to a user as shown in below images.
I would like something where I can present options to a group chat or channel.
But if you want to present options to a group chat or channel AFAIK there is no such built-in connector available in logic Apps. You can achieve this using Adaptive cards.
Adaptive cards for Microsoft teams
By following this document, you can add radio buttons or by changing test as an option you can create buttons labeled option1 and option2 as per your requirement.
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Text Block",
"text": "Please select an option:"
}
],
"actions": [
{
"type": "Action.Submit",
"title": "Option 1",
"data": {
"id": "option1"
}
},
{
"type": "Action.Submit",
"title": "Option 2",
"data": {
"id": "option2"
}
},
]
}
Reference link

Unfurl links blocks template

I'm using the link_shared events to unfurl links in my workspace, trying to generate a template that is as close to Slack's unfurling template as possible, but I have several issues -
Blocks have very large spacing between them, causing my 3 blocks to take a lot of space
I'm unable to have an image inlined with the text for the title, unless I'm using context, but this is causing the text to be very small.
Taking Slack's example of how link unfurling should look like and trying to mimic it with blocks should explain the differences. This is the blocks message, and here you can see the result as an image
So my main question is - does Slack use some internal blocks formatting not available in the API, or is it possible to achieve the same result?
Thanks a lot!
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":pager: *Slack*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<https://slack.com/features|Features>*"
}
},
{
"type": "image",
"title": {
"type": "plain_text",
"text": "Slack is where work flows. It's where the people you need, the information you share, and the tool you use come together to get things done.",
"emoji": true
},
"image_url": "https://a.slack-edge.com/13f94ee/marketing/img/homepage/self-serve-campaign/unfurl/img-unfurl-ss-campaign.jpg",
"alt_text": "Slack"
}
]
}
That example is not using the Slack block unfurl - it's an example of how a generic link would be displayed using the page's meta tags to display some additional information, using the favicon image.
If you wanted to create something similar you could use use a markdown block and an image block (like this) - but the file size would be displayed on a new line rather than after the text.
It took a bit of playing around, but I realized Slack is actually using message attachments (the legacy version of message formatting) in order to generate their link unfurls.
For example, if you want to unfurl a GitHub repository link, this is the payload you should send, and it'll generate an almost identical unfurling to what Slack is generating (a small Added by {app-name} will be added to the footer) -
unfurls["https://github.com/slackapi/bolt-js/"] = {
author_name: "GitHub",
author_icon: "https://a.slack-edge.com/80588/img/unfurl_icons/github.png",
title: "GitHub - slackapi/bolt-js: A framework to build Slack apps using JavaScript",
title_link: "https://github.com/slackapi/bolt-js/",
text: "A framework to build Slack apps using JavaScript. Contribute to slackapi/bolt-js development by creating an account on GitHub.",
image_url: "https://opengraph.githubassets.com/3e06f7eee96f05a53cd4905af3b296dfe333be7a902bb3e6a095770e87fd17fe/slackapi/bolt-js"
}

Microsoft Graph: insert a message (mail) to user inbox

I have a Microsoft application (with Mail.Read/Write permissions) and I need to insert a mail (.eml extension file) to a user inbox.
Is that possible? I know that with Gsuite that can be done using the 'insert' API and was wondering if something similar exist with Graph API.
I'm not talking about sending new mail to the user or about inserting an attachment to existing message in the user inbox, but to insert completely new email to his inbox (without having to go through SPF or whatever checks that take place before mails usually get into end users inboxes).
Looking into Mail section under Graph API documentation wasn't so helpful.
If that not possible, perhaps there is a workaround?
EDIT: seems like the best option is to use "send mail" API and specify "saveToSentItems": False.. the only issue here as that my application will need to request the Mail.Send permission as well..
Thanks
You don't need to use the send mail api as all your doing is creating an Item in the Mailbox. If you want it to appear as a Sent Mail (rather then a draft) you do need to set the PidTagMessageFlags extended property (the same as you would in EWS https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-import-items-by-using-ews-in-exchange). Also if you want it to appear if its been sent in the past there are few additional extended properties you need to set. eg
{
"Subject": "test1234",
"Sender": {
"EmailAddress": {
"Name": "blah",
"Address": "blah#blah.com"
}
},
"Body": {
"ContentType": "HTML",
"Content": "123Body"
},
"SingleValueExtendedProperties": [
{
"PropertyId": "Integer 0x0E07",
"Value": "1"
},
{
"PropertyId": "SystemTime 0x0039",
"Value": "2019-06-12T10:10:47.2048+10:00"
},
{
"PropertyId": "SystemTime 0x0E06",
"Value": "2019-06-12T10:10:47.2048+10:00"
}
]
}

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.

Strategies for sending weekly newsletter emails from Rails

So we have about 50,000 users who have signed up for a weekly newsletter. The contents of this email is personalized for each user though, it's not a mass email.
We are using Rails 4 and Mandrill.
Right now we're taking about 12 hours every time we want to fire off this emails.rake task and I'm looking for a way to distribute that time or make it shorter.
What are some techniques I can use to improve this time that is only growing longer the more people sign up?
I was thinking of using mandrill templates, and just sending the json object to mandrill and have them send the email from their end, but I'm not really sure if this is even going to help improve speeds.
At the 50,000+ level: How do I keep email sending times manageable?
Looks like you could use MailyHerald. It is a Rails gem for managing application emails. It sends personalized emails in the background using Sidekiq worker threads which should help you out in terms of performance.
MailyHerald has a nice Web UI and works with email services like Amazon SES or Mandrill.
You need to probably look into Merge Tags on Mandrill. It allows you to define custom content per email. So you can break your newsletter sending into fewer API calls to Mandrill instead of 1 per email. The number of calls will just depend on the size of your data since I am sure there is probably a limit.
You can just create a template and put in merge vars such as *|custom_content_placeholder|** wherever you need user specific content to be placed. You can do this templating in your system and just pass it into the message or you can set it up in Mandrill and make a call to that template.
When you make the Mandrill API call to send an email or email template you just attach the JSON data such as:
"message": {
"global_merge_vars": [
{
"name": "global_placeholder",
"content": "Content to replace for all emails"
}
],
"merge_vars": [
{
"rcpt": "user#domain.com",
"vars": [
{
"name": "custom_content_placeholder",
"content": "User specific content"
},
{
"name": "custom_content_placeholder2",
"content": "More user specific content"
}
]
},
{
"rcpt": "user2#domain.com",
"vars": [
{
"name": "custom_content_placeholder",
"content": "User2 specific content"
},
{
"name": "custom_content_placeholder2",
"content": "More user2 specific content"
}
]
}
],
You can find more info on Merge Tags here:
https://mandrill.zendesk.com/hc/en-us/articles/205582487-How-to-Use-Merge-Tags-to-Add-Dynamic-Content
If you are familiar with handlebars for templating, Mandrill now supports it with the merge tags:
http://blog.mandrill.com/handlebars-for-templates-and-dynamic-content.html

Resources