Using local path in Twilio mediaURL - twilio-api

Does anyone know if a local path can be used to add a mediaURL to a Twilio SMS?
So:
MediaURL=file:///Users/Name/file.gif
Rather than:
MediaURL=https://server/file.gif

You cannot use a local path. The media url has to be publicly accessible to Twilio's servers (ie it has to have a URL) so that the asset can be retrieved and added to the message. If it were accepted, that path would point to "/Users/Name/file.gif" on a random Twilio server. This is also why localhost based urls will not work with Twilio. If you are doing local development using Twilio you'll either need to use an IP address in your url or you'll need to use a service like ForwardHQ to provide a domain for your local webserver.
The MediaURL needs to be an absolute path, not a relative one.
Here is an example from Twilio's API docs using a MediaURL: https://www.twilio.com/docs/sms/send-messages#example-1
Here's the specific code snippet: https://www.twilio.com/docs/sms/send-messages?code-sample=code-send-a-message-with-an-image-url&code-language=rb&code-sdk-version=5.x
Update: our good friends at ForwardHQ have closed their doors. I am now using Ngrok.com to expose my local webserver to the internet.

You can host the files using ngrok and share the local files externally.
Media url will be available for Twilio to access and will be shared to the recipients using twilio api.

Related

Dialogflow fulfillment URL issue

I am creating a voice-bot using dialogflow with google assistant. My client has provided his network access, which is not a private URL an IP instead. It is not SSL certified too. I will get two errors this time
Only public URLs are allowed and
You can use only https:// in fulfillment url when "Google Assistant" integration enabled
Any workaround for this? What are the other options I have? I can access clients API within his network only. So I cannot replace this IP address. Please advise how to proceed further.
You can use an IP address, as long as it is a public IP address. The machine doesn't need a DNS entry.
Actions on Google requires an HTTPS connection, however, using a valid certificate (ie - not self-signed). This is to protect your client and their users data.
One possible workaround is to look into a tunnel/proxy service such as ngrok. They provide a public HTTPS address that securely tunnels to an ngrok client you run on the same machine as the webhook fulfillment server. They have a free service that will change hostnames periodically, or you can subscribe to a commercial service which will give you a fixed name which you can use for the fulfillment URL.
You have to make URL https://.
you can try https://letsencrypt.org/

Can i use localhost as a URL Callback in a messenger webhook

Good evening, just saw that Facebook released his messenger bot toolkit and i immediately jumped right into it to learn more about it and maybe try to do my own.
My problem is that i don't have a https website running and it requires a https valid url. I tried to use my local web-server that has a certificate but it doesn't work.
My question is if this is possible to be done using a localhost url at all.
Thank you in advance
Actually this is possible with localhost. Use ngrok. It allows you to open localhost to the public web, over http or https. This should only be used for testing however.
If you want to test webhooks on your local environment, I would try ultrahook.com, you can get an API Key for free and the tool creates a tunnel from a public URL to your computer. This is from their FAQs page:
You download and run the UltraHook client on your computer. It
connects to UltraHook servers in the cloud and creates a tunnel from a
public endpoint on our servers to your computer. Any HTTP POST
requests sent to the public end point will be sent through the tunnel
an delivered to a private endpoint accessible from your computer.
I have used it to test webhooks from different providers (like payment gateways). In your computer, you can run something like:
ultrahook <subdomain> http://localhost:8000/webhook/
and then configure the webhook URL in your external service to something like <subdomain>.ultrahook.com
My question is if this is possible to be done using a localhost url at all.
No, of course it isn’t – because what such a “callback” actually means, is that Facebook makes a request to your server – and that is hardly possible with localhost.
A valid SSL certificate for your website is easy to get for free these days, via LetsEncrypt. And even if that is not available on your server, there’s still StartSSL, that provide basic certificates for free. All you need is a server you can install them on, or upload them to, or whatever mechanism your hoster provides for it. (And if they don’t provide any, then it might be time to switch.)

Informatica Facebook connection

I have a little problem. I have installed Informatica server on Guest VM that has hostname info-hadoop with bridge network(in mean that other Computers in LAN can see and use it without any extra NAT rules).
On computer that use Informatica server in /etc/hosts was added
IP info-hadoop
To create Facebook connection i followed official manual and this video .
Here i got problem with Valid OAuth redirect URIs. Under
https://info-hadoop:8443/ows
i have such OAuth Callback URL:
https://info-hadoop:8443/ows/jrs/callback
But i can't enter this URL in
https://developers.facebook.com/apps/myappID/settings/advanced/
Facebook doesn't allow to save this URL. So i tried to use such link
https://info-hadoop.com:8443/ows/jrs/callback
With proper added lines on /etc/hosts:
IP info-hadoop info-hadoop.com
But facebook throws exception(in video at 3:30)
Given URL is not allowed by the Application Configuration
What should i do?

How to get my files using a secure connection (https)

I want to host my pictures in a secure server(https).
My app is using https in all webpages so I don't want to run into problems of
browsers saying that my webpage isn't safe.
And I was wondering if I can do this in Google Cloud Storage.
Google Cloud Storage works just fine over HTTPS. Just retrieve pages from 'https://storage.googleapis.com' instead of from 'http://storage.googleapis.com'.
Note that there's one exception: you cannot use HTTPS for custom domain name buckets. So if you create the bucket 'example.com', you can access it at 'https://storage.googleapis.com/example.com' or at 'http://example.com' but not at 'https://example.com'
I found out that you only need to type manually the https as protocol that it is going to work just fine.

How to test Facebook Real-time updates

In order to publish real-time updates to my app, Facebook needs needs to perform a post request to my server.
Problem is, my server is my home computer and not publicly addressable from the internet. Bringing a server live to implement this sounds like it could be a pain... can't attach debugger, fiddler etc....
So what's the best way to test the Http Endpoint? Integration tests that simulate the Facebook server? Fiddling with firewalls/NAT to try and get Facebook talking to my home computer?
Any ideas?
You can use ngrok - https://ngrok.com/ - free (pay-what-you-can) service that does exactly what you need. Localtunnel service is down and the developers also recommend ngrok.
In the past, I've used LocalTunnel to do this. It's a nice wrapper around an SSH tunnel and it effectively assigns you a subdomain at localtunnel.com pointing to a port on your localhost.
So basically, when you run it it will spit back an externally accessible sub domain name like xyz.localtunnel.com who's port 80 will point a port you specify on your local box.
You can find it at: http://progrium.com/localtunnel/
It's really great for testing various pubsubhubbub subscription feeds (like Facebook's).
OK! I think NAT should be the best bet and I don't see a reason for it not to work. You should try it out.
It was actually pretty easy - Logged into my home router, set up port forwarding on port 80 to the local IP of my computer, put an exception in windows firewall for port 80. and then navigate to my public IP address in the browser.
Implement the receiver samples at: https://github.com/facebook/real-time/tree/master/samples
The only answer is to get a webserver that is publicly accessible for real-time updates to be able to call back to.
There's lots of free webhosts that allow server-side scripting. And there's lots of paid for webhosts out there too. Stackoverflow is really not the place to get leads on where/when/why/howmuch for web hosting.
No you can't use ngrok only to simulate facebook realtime update since you must make a call to facebook servers with your ngrok adress to validate it (tell me if you find out how to do this :p ).
I use an openshift server to receive facebook realtime and then post evry json data received from facebook to my ngrok adress. So the process is
set up an openshift server to receive facebook notifications
Facebook sends notifications to your openshift
your openshift sends datas (as received) to your ngrok adress
And if you must receive facebook notifications on a local website (like www.website.dev/fb-notifications/) then create a script in your localhost folder which receives openshift posts (let's call it tunelscript.php). the process will be
set up an openshift server to receive facebook notifications
Facebook sends notifications to your openshift
your openshift sends datas (as received) to your tunel script via your ngrok adress (perso.ngrok.com/tunelscript.php)
Relay datas from your tunelscript to your local website (tunelscript.php => www.website.dev/fb-notifications/)
That's Tuneling B-)