how to get POST webhook with geo data from Whatsapp - while using studio flow - twilio

So i use studio flow for a whatsapp interaction. Sometimes our users lack internet, so we have an option to send locations in offline mode.
Once reconnected, we initiate a http_request in studio, that then uses the Twilio API to get all the inbound messages the user has been sending to whatsapp while offline. The http request only gets the last message send, so not the previous maybe 6 - 20 messages.
I can get the body text of all those, when i perform CLIENT.messages.stream. But not the geo information. As those are send in the Webhook POST request, that go to studio flow.
My question is thus how can i get the latitude/longitude? Is it possible at all?

Twilio does not store the geolocation data sent via WhatsApp. So you'll have to accept the geolocation data via the webhook HTTP request and store it somewhere else if you need to retrieve it later.

Related

Verify SMS received in Twilio is from a real phone and not a spoofed POST request

I'm creating an app where a user can sign up for phone notifications. We're verifying users by sending them a text message and then having them respond "YES" or "NO" to receive text messages.
However, we're concerned that users might be able to spoof sending a message to our webhook by using a POST request to it with just enough data to verify them. Is there a way in Twilio to detect if an incoming request is from Twilio or not?
This is possible with more information here - X-Twilio-Signature. There are also a few different blog posts detailing its use, for example, How to secure Twilio webhook URLs in Node.js.

Triggering a Twilio function to write a record in an external service (e.g. a CRM) whenever an sms message is SENT via Twilio

What the title describes can already be done easily via programs like Zapier, so I am hopeful that it can be done through Twilio functions directly.
Essentially, I have my CRM set up so that based on certain triggers, it sends a http POST request to the Twilio URL that controls SMS sending:
https://api.twilio.com/2010-04-01/Accounts/ + twilioAccSId + /Messages.json
For the most part, this works great!
I just want a way for Twilio to then respond by using a function to write a record into the CRM (using the CRM's APIs).
I would want the record written to include things like the delivery status of the message e.g. whether it failed, or was successful). I'm also open to exploring other ways where Twilio can transmit this outbound message info to the CRM through other means, and then having a function on the CRM then write a record!
Do you have the code to share of what you are attempting and the issue encountered? Or is the question more if this is possible? It is certainly possible.
You will use a statusCallback URL of your outbound POST to the messages resource, which will fire with the statusCallback messages and make an API call to your CRM to update the customer record accordingly. You can append a URL query parameter to your statusCallback, so you know which customer record to update.
Track Delivery Status of Messages
How to Share Information Between Your Applications
Passing Custom Information via Requests to Twilio

Twilio not sending webhooks in Progammable Chat

I would like to ask a question or maybe report a bug after solving my doubts. I started working with Programmable Chat and Twilio do not want to send a webhook to specific url but only when I'm sending message from my PHP code. I downloaded example node app and sending message from that, everything is working really nice, I'm getting post request from Twilio but if only I will send message from PHP, nothing at all. And strange is, after sending message from PHP, it will appear immediately in chat which means that it's working.
How does it possible? Could it mean that Twilio on theirs backend has an a bug when they receive message from PHP and becuase of that they are not fire webhook event?
I eliminated all differences, everything is that same beside that one message is sending from PHP and another from node. Same situation from API Explorer.
Gif presentation
Twilio developer evangelist here.
When you send messages to Programmable Chat from the REST API then webhooks aren't triggered. I think the reasoning is because you are making the call from your server, then your server is already aware that you are sending a message and you don't need to receive a webhook to do so. It also saves from the potential of infinite loops (if your webhook sends a message via the REST API, the requests would just go in circles).
So, it's not a bug, but a design choice. If you need to trigger your webhooks when you send a message from the REST API, you will need to make the webhook from your own server.

HTTP GET request for user's phone number in fulfillment editor

We are setting up a chat bot through Dialogflow. A user will receive a weblink to the bot in a call or SMS sent through twilio. I'm wondering if it is possible for us to set up an HTTP get request to twilio in fulfillment so that we can set a context parameter to the user's phone number in the fulfillment inline editor in Dialogflow.
I took a look at twilio's api docs but could only find information on HTTP requests regarding numbers purchased or available for purchase through twilio.
So to clarify: in Dialogflow's fulfillment inline editor, we want to set a context parameter equal to the user's phone number that twilio called or sent the SMS to with a weblink to our chat bot.
Thanks!
Twilio developer evangelist here.
If I'm understanding right, you want to send a URL to a user via SMS (or over the phone?) which will link them to a web based chat with your bot. And you want to be able to link that chat back to the original phone number?
If that is the case, then the first thing that comes to mind for me would be to create a unique URL for each phone number you send this message to. If you store a link between the URL and the number it is sent to in a database somewhere, then when th euser clicks through to it you can recover the phone number and apply it to your Dialogflow context.
I don't believe you need to make any requests to the Twilio API for this aside from sending the initial SMS.
I hope this helps.

Receiving notifications of new posts on Twitter via a specific URL

I would like to access the messages in the Twitter via the API in real time. A cursory search showed that it is possible to periodically send API-request to Twitter. In general, this is possible. 15 requests in 15 minutes is enough.
But I'm wondering, are there other ways to get information faster?
For example, is it possible to subscribe to notifications and receive a request from Twitter at a certain address?
Are you asking if Twitter has webhooks? The answer is yes
Review Securing Webhooks documention taking special note of the
Challenge Response Check (CRC) requirements.
Create a web app with an endpoint to use as your webhook to receive
events (e.g. https://example.com/webhook/twitter).
Make sure your webhook supports POST requests for incoming events and
GET requests for the CRC.
Register your webhook URL with your app using POST
account_activity/webhooks.
Use the returned webhook_id to add user subscriptions with POST
account_activity/webhooks/:webhook_id/subscriptions.

Resources