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

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.

Related

Get Whatsapp Number of user in Twilio autopilot

I am trying to create a chatbot using Twilio Autopilot which integrated with WhatsApp. So my flow is like, if user messages on registerd number, Twilio WhatsApp senders webhook will get trigger and it will call Autopilot chatbot task. Task will process the data and it will send reply.
In all above flow I want to capture the WhatsApp number of the user who is asking the question. that number I want in autopilot, so Autopilot will send that number to Twilio function and I want to save that number in my Database using external API's call from Twilio function.
How I will get WhatsApp number inside Twilio Autopilot chatbot for user who is asking questions?
Thanks in Advance
Autopilot can respond using static actions defined within the task, but it can also send a webhook request to fetch Actions JSON from your server. That webhook request contains details about the user you are talking with, including the parameter UserIdentifier which, in a WhatsApp chat, will be the user's WhatsApp number.
If you are currently responding to tasks from Actions JSON defined in the Twilio console, you can add a webhook by using a "redirect" action at the end of a set of actions to a URL you control and then responding to that with a "listen" action to wait for the next task. Alternatively, you could just set a URL for the webhook and respond with your Actions JSON from your own app.

Prevent Twilio SMS Instant-Auto-Response "OK"

I have a Twilio integration setup with an application I am building. The application allows users to send and receive text messages to/from a Twilio phone number.
For example, assume you're a user. When you create an account, you receive a phone number -- this phone number is purchased and managed via Twilio. You can then use this phone number to send and receive regular text messages.
To send, it's easy, just make the Twilio API call.
To receive, I'm using the webhook integrations. Meaning, I have a hosted server at https://my-website.com/api/sms/receive. Any time some external person sends a text message to the Twilio phone number, Twilio will send a HTTP POST request to my server.
The problem: Twilio is auto-responding, immediately, to the external persons phone number with OK. I cannot find any documentation about how to prevent this from happening.
I'll provide a real-world use case as an example.
Say Bob is a user of my application. Bob have a Twilio phone number through my app. Bob wants to send a text message to Alice. Alice is not a user of the app -- they're just some external person. Bob is using the app to communication with Alice via Alice's normal phone number.
Bob sends a text to Alice via the Twilio integration
Alice receives the text message on their phone
Alice responds back to Bob's text
Twilio triggers my server webhook integration
Twilio immediately auto-responds back to Alice with OK
(5.) is the problem -- I don't want this to happen
I found the solution. Turns out the webhook API needs to use the TwiML (Twilio Markdown Language) to instruct Twilio not to respond. https://support.twilio.com/hc/en-us/articles/223134127-Receive-SMS-and-MMS-Messages-without-Responding
Specifically, my server just returns a Content-Type of text/html and the body is simply <Response></Response>

Is it possible to send an Twilio SMS with a custom "from" or "reply-to" number?

I was tasked with writing a web app which would allow customers to type and send a message on their browser (mobile or desktop) to a business. I was able to achieve this using Twilio, however the business requested that they received the messages from the customer themselves and NOT the Twilio number.
Basically, they want to establish a connection between the customer and the client via SMS
This is the way I forwarded the message:
Customer Browser -> Twilio -> Business Phone
The SMS body would include customer message, name and phone number.
The problem with this approach is that the business employees want to be able to simply press "reply" on their phone messaging app and connect directly with the customer instead of receiving the text message from a Twilio number, and starting a new message to send to the customer (apparently this doesn't integrate properly with their database).
Is there a way to send an SMS from a Twilio number but appear as if it was sent from a customer number? Hence, change the "from" / "reply-to" number.
Thank you.
Edit: I think its possible that I request and authorize customer numbers to my Twilio account. However this would mean storing customer phone numbers and I'm not sure if I have the permission to do this.
This is how you send a message (NodeJS):
client.messages.create({
body: 'Hello from Node',
to: '+12345678901', // Text this number
from: '+12345678901' // From a valid Twilio number
})
The from attribute MUST be a valid (authorized) Twilio number. Hence why customers would need to give away their number in order to become valid.
In my opinion, this is not possible and that is very good so. Think about the implications if you could just send a message from a number that you don't own. Furthermore, it is not optimal if you would request access to your customer's phone numbers. However, you could use the Twilio proxy service in order to set up the conversation between the client and the customer. For more information please visit the proxy docs. It is still in Beta but works reliably IMO.
You cannot.
Even with the authorized numbers feature, it requires an opt-in via a phone call or SMS response which your customer would have to field.
Perhaps allow a customer to include their number in the message body, which with modern phone's is as simple as clicking the number to bring up the ability to message that number
For more info see here twilio docs

Twilio Opt-In/Opt-Out API

I am working on an Opt-In /Opt-Out api that integrates with Twilio. The way our Opt-In/Opt-Out works is each company (our customer) signs up for one or more Twilio phone numbers and their customers can opt-in/opt-out into these numbers.
When Twilio receives these opt-in/opt-outs we want Twilio to call us into a webhook URL.
So my question is: how do we register these callback URLs? Do these have to be defined at the time when each company signs up for a phone number? If so whats the API end point for that?
These numbers can be added by different companies at any time. Please advise how to do that. We already have URLs defined for sending and receiving SMS messages with Twilio. In this case we first send the message to Twilio and we specify a callback url in that. Can the Opt-In/Opt-outs work with these already registered end points?
All the phone numbers these companies sing up for are created as a subaccount under us. So is that fine with Twilio and can Twilio call us back on the already registered end points (URLs).
If you have any documentation on how to set up an Opt-In/Opt-Out,please include that. I couldn't find one anywhere. The API method we use for creating subaccounts when companies sign up for a phone number is CreateSubAccount and there is no parameter to specify an call back endpoint URL. I tried contacting their support but they haven't gotten back to us yet.
Twilio developer evangelist here.
I'm not sure exactly what you mean when you say "When Twilio receives these opt-in/opt-outs" as the only thing you will get webhooks for is when a number receives an incoming SMS (or phone call, but we're talking SMS right now).
You can set a different SMS webhook URL per each phone number using the API when you buy the phone number. As part of the POST request to the Incoming Phone Numbers resource you can add the optional parameters SmsUrl and SmsMethod.
Once you have purchased the number, you can also update the webhook URLs for it, by POSTing or PUTing to the instance resource, using the same parameters.
Let me know if this helps at all.

Override Message Service inbound URL programatically

I have setup a trial Twilio account and have been investigating their
Programmable SMS service. Within my account I have also setup a Messaging Service. When I send an SMS I am able to set the URL I wish Twilio to send all delivery events (e.g accepted, sent, delivered etc) to, using a field called statusCallback. However, I am wondering if it is also possible to set the URL for which I wish to receive any replies to the message being sent, as part of the send SMS call? I know I can change the incoming request URL within the Messaging Services area of my Twilio account dashboard, but I would like to be able to set this URL on a per SMS basis, as part of the send SMS API call.
Does anyone know if this is possible? I cannot see anything in the docs to suggest it is but I wanted to know definitively.
I hope the question makes sense but if any clarification is needed then please let me know.
Thanks,
Paul

Resources