Twilio autopilot handoff action is not working with Twiml Bin - twilio

I have a Twilio autopilot task from an incoming call, which performs a greeting then asks a question before redirecting to a new task called 'callnumber'. This all works fine.
The 'callnumber' task looks like this
{
"actions": [
{
"handoff": {
"channel": "voice",
"uri": "https://handler.twilio.com/twiml/TWIMLBINID"
}
}
]
}
TWIMLBINID actually has the correct ID from the Twiml Bin.
This is the Twiml content in the bin:
<Response>
<Say>I will put you in contact with our customer care specialist.</Say>
</Response>
Unfortunately I'm not hearing this Response spoken out and instead just get the standard 'an error has occurred' voice message.
I've tried a few different versions of this, even calling an xml file hosted on my own public web server and seeing the same problem. Also tried the dial verb and still seeing this issue.
I feel like I may have missed some configuration, after seeing similar posts like: Twilio autopilot doesnt say what it is supposed to say
Any help is much appreciated!

I was able to get the TwiML Bin working with similar JSON, when I have it associated with a Task that has samples.
So, for example, a call comes in to your Autopilot assistant and initially triggers the Assistant Initiation Task of hello_world where you modified the predefined JSON with a listen action.
{
"actions": [
{
"say": "How can I help you today?"
},
{
"listen": true
}
]
}
You then respond so the task associated with your handoff JSON/TwiML Bin is executed (based on the samples you provided). If you try to call the handoff task directly, it fails.

I have the same JSON for "actions" of the task-seems perfect.
But 2 Small differences for the TwiMLbin :
1)don't forget to put the xml tag in the TwiLbin :
It should be :
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>For this question, I will put you in contact ...</Say>
</Response>
2)I don't understand how your twiMLbin has such an hyperlink. Normally the syntax is
https://handler.twilio.com/twiml/******SID******
and the SID can not be chosen and mine has 34 characters. (do not use the "friendly name" of the twiMLbin). You have a button in the twiMLbin to copy-paste it directly.
for me it works. Otherwise please provide some more elements
-do you have queries associated to the autopilot task ? if you have task(s) that do not have any queries, the model will refuse to build (you can check this in the screen "natural language router" / tab "build models").
-are you sure you don't have conflicting query that triggers another task than the one you think (typically with short queries, they "vampirize" other intents). For that please provide the logs of the queries (query Vs Task) of your autopilot assistant.
nb : I confirm what philnash said : you should really try with a phone call. I experienced also some "glitches" with the Twilio simulator.

Related

Gmail API, Reply to thread not working / forwarding

I'm using the google gmail api in swift. All is working well, it's compiling etc.
I'm now trying forward an email, the only way I see this possible so far is by using a thread id.
So I'm using the API tester found here to send tests. Will will focus on this. It can be found here1
So I've input this, the "raw" is Base64 URL encoded string.
{
"raw": "VG86ICBlbWFpbFRvU2VuZFRvQGdtYWlsLmNvbSAKU3ViamVjdDogIFRoZSBzdWJqZWN0IHRlc3QKSW4tUmVwbHktVG86ICBteUVtYWlsQGdtYWlsLmNvbQpUaHJlYWRJZDogIDE1YjkwYWU2MzczNDQ0MTIKClNvbWUgQ29vbCB0aGluZyBpIHdhbnQgdG8gcmVwbHkgdG8geW91ciBjb252by4u",
"threadId": "15b90ae637344412"
}
The "raw" in plain text is
To: emailToSendTo#gmail.com
Subject: The subject test
In-Reply-To: myEmail#gmail.com
ThreadId: 15b90ae637344412
Some Cool thing i want to reply to your convo..
when I execute it I get this back
{
"id": "15b944f6540396df",
"threadId": "15b90ae637344412",
"labelIds": [
"SENT"
]
}
But when I check both email account, from and to. None of them say the previous messages but are in the same "thread" or convo.
If anyone can help it would be much appreciated I've spent all day on this issue and half of yesterday and did TONS of research on it.
as stated here I should I'm adding the threaded and In-Reply-To in the right way I believe
The ID of the thread the message belongs to. To add a message or draft to a thread, the following criteria must be met:
The requested threadId must be specified on the Message or Draft.Message you supply with your request.
The References and In-Reply-To headers must be set in compliance with the RFC 2822 standard.
The Subject headers must match.

Only I can see my output from custom slash commands

I created a custom slash command in Slack. The backend code, not that it's important, is a Lambda function in Python in AWS.
My problem is that when I enter the slash command, I am the only one who can see the message. Otherwise, it works perfectly. Is there a way to get others to see the output from my custom slash command?
See "'In Channel' vs. 'Ephemeral' responses" here: https://api.slack.com/slash-commands#responding_to_a_command.
By default, the response messages sent to commands will only be
visible to the user that issued the command (we call these "ephemeral"
messages). However, if you would like the response to be visible to
all members of the channel in which the user typed the command, you
can add a response_type of in_channel to the JSON response, like this:
{
"response_type": "in_channel",
"text": "It's 80 degrees right now.",
"attachments": [
{
"text":"Partly cloudy today and tomorrow"
}
]
}
When the response_type is in_channel, both the response message and the initial message typed by the user will be shared in
the channel.
If you have a block in your JSON payload to slack (you used slacks block-kit) e.g
`"blocks": []`
you'll have to put the "response_type": "in_channel" above blocks for it to work :) e.g
{
"response_type": "in_channel",
"blocks": [....]
}

Slack Slash Command - Image Not Unfurling

I have written a custom Slash command that takes in a query from the user and returns an image.
The Server side which receives the Slash command retrieves the query from the user, and forms the Image URL http://example.com/file1.png and it sends back the response as <http://example.com/file1.png>. This is shown as a link in the response and is not unfurled. What could be the problem?
I even tried the following:
1) I sent back a JSON payload as given below:
{
"text":"http://example.com/file1.gif","unfurl_media":true
}
But that displayed the link again and did not unfurl it.
2) I tried
{
"text":"<http://example.com/file1.gif>","unfurl_media":true
}
But same results.
What could be the problem? Do I absolutely need a incoming webhook integration and send the message there ?
Did it work the first time, or had the URL previously been unfurled?
Slack will only automatically unfurl a URL once per hour in a given channel. If a user manually posts the URL and it is not unfurled because of this limit they will get an ephemeral message from SlackBot about it, however the unfurl just silently fails for slash commands or webhooks. I've hit this before in testing and had to make sure to change either the URL or the channel to verify things are working.
You should not need a manual attachment or a webhook or even the unfurl_media flag in the response (it's on by default for messages posted via webhooks/slash command).
I was having a similar issue with slash commands returning the text of my image url.
What you need to change is to use an object with an image_url for your image, and put that inside an attachments array.
Below is an example that returns the link of the image as text and the image itself.
{
"parse": "full",
"response_type": "in_channel",
"text": "http://example.com/file1.png",
"attachments":[
{
"image_url": "http://example.com/file1.png"
}
],
"unfurl_media":true,
"unfurl_links":true
}
{
"parse": "full",
"text": "http://example.com/file1.png",
"attachments":[
{
"image_url": "http://example.com/file1.png"
}
],
"unfurl_media":true,
"unfurl_links":true
}

Twilio call forwarding for specific time of day

With Twilio I'd like to implement a service that sends inbound calls to a voice recording during specific times of day.
Can Twilio provide this behavior?
Twilio developer evangelist here. You can absolutely do that! I'm not sure what language or framework you're using, but here's an idea of how you'd accomplish this.
When Twilio receives a call on a Twilio number it makes a webhook request to your server to respond and tell it what to do with the call. The instructions are built in XML (TwiML). So, to do time based stuff you probably want to do something like this (my example is in Ruby using Sinatra as a web framework):
post '/call' do
time = Time.now
content_type 'text/xml'
response = "<Response>"
if out_of_hours?(time)
response = "<Say>Please leave a message</Say><Record />"
else
response = "<Dial><Number>YOUR_PHONE_NUMBER</Number></Dial>"
end
response = "</Response>"
response
end
You can then define out_of_hours? to follow the rules you want.
I hope this help, please let me know if you have any other questions.
Here is cakePhp - twilio url is xyz.com/Aptw/dialMtmTextJobLine/ - see the view function slap in the middle of the example.
<?php
App::uses('AppController', 'Controller');
class AptwController extends AppController {
public function beforeFilter() { $this->Auth->allow(); }
public $forwardIn = '<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Sip>';
public $forwardOut = '</Sip></Dial></Response>';
public function dialMtmTextJobLine() {
date_default_timezone_set("America/New_York");
$t=date("H:i",time());if ($t>"09:00" && $t<"16:00") {$this->dial103(); }
else { $this->dial2223(); }
}
public function dial103() { die($this->forwardIn.'sip:103#myast.com' . $this->forwardOut); }
public function dial2223() { die($this->forwardIn.'sip:2223#myast.com' . $this->forwardOut); }
}
Between 9am and 4pm, when twilio fetches the xml from your app, it sees one thing, and outside of that it sees another. Twilio is amazing, but it is meant to be just part of the answer, and I respect that.
Watch your formatting on the xml, Twilio is particular. I had tried to scrunch everything on one line and Twilio would not parse it.
This example does not properly use view templates, I get that. It's not entirely cakey, instead of dying, and instead of using the class variables to contain the xml boilerplate, I'll end up moving that to a view, making this code even shorter.
In fact, dial103 could be rendered with a view with no php inside it.
But better yet, direct dial urls for Twilio could look like xyz.com/Aptw/dialx/103 for my purposes. In cakephp you parse the next argument after controller Aptw and action dialx like thus: function dialx($extension) ... and the 103 automagically jumps into the $extension variable. Then you set a variable for the view, that's cakey.

Problems with sharing via LinkedIn a link with equal sign

I've encountered an issue with LinkedIn share API.
I am working on a iPhone project, testing my application on iOS 4.0, 5.0.
I used this project as an example:
[https://github.com/synedra/LinkedIn-OAuth-Sample-Client][1]
I thought I am a genius after successfully implementing this API not only for sharing an update, but also with following format(like shown in [https://developer.linkedin.com/documents/share-api][1]):
<?xml version="1.0" encoding="UTF-8"?>
<share>
<comment>83% of employers will use social media to hire: 78% LinkedIn, 55% Facebook, 45% Twitter [SF Biz Times] http://bit.ly/cCpeOD</comment>
<content>
<title>Survey: Social networks top hiring tool - San Francisco Business Times</title>
<submitted-url>http://sanfrancisco.bizjournals.com/sanfrancisco/stories/2010/06/28/daily34.html</submitted-url>
<submitted-image-url>http://images.bizjournals.com/travel/cityscapes/thumbs/sm_sanfrancisco.jpg</submitted-image-url>
</content>
<visibility>
<code>anyone</code>
</visibility>
</share>
Following advices and examples, I was preparing a JSON string that i was using.
So, i got this:
{
"visibility":
{
"code":"anyone"
},
"comment":"Asd",
"content":
{
"submitted-url":"http://google.com",
"title":"googloo",
"submitted-image-url":"http://pikci.ru/images/img_srchttpwwwcomputerrivercomimagessamsung-chat-335-qwer.jpg"
}
}
Well, with this data inside, it works like a charm. the update is with image, clickable title and stuff. Perfect.
Then, i tried to put a link(because i really needed in purpose of my project) with a Equal sign in it: "=", like for example we have
http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881
Well, if we use this link in submitted-url, and send it, the LinkedIn will receive it, and even will give us a response. But it WONT update to the new status! It's a huge bug for my application, because the share won't work, but more than a half of the shared links will have equal sign in it. It is the third day when i'm fighting with it. I was trying different coding functions, different "smarty-pants" moves, but failed.
If anyone has a clue about what is going on here, I will hugely appreciate it...
When I post this body to LinkedIn I get my status updated:
{
"comment": "Posting from the API using JSON",
"content": {
"submitted-url":
"http://www.google.md/#q=Nicolas+Steno&ct=steno12-hp&oi=ddle&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=8c5a975d815425a&biw=1920&bih=881"
}, "visibility": {
"code": "anyone"
}
}
However, the link itself doesn't resolve correctly. It's likely that something about that URL is tripping up our link shortener - we're working on fixing these issues but in the meantime you could use something like the Google URL shortener URL:
body = {"longUrl": article['articleContent']['resolvedUrl']}
resp,content = http.request("https://www.googleapis.com/urlshortener/v1/url?key=xxx","POST",body=simplejson.dumps(body),headers={"Content-Type":"application/json"})
googleresponse = simplejson.loads(content)
... and then share that to LinkedIn. I realize it's a suboptimal solution, but until the share function gets fixed to handle these URLs it should get you going.

Resources