"Number to Contact" does not send message when edited - twilio

When I change the {{contact.channel.address}} number to a different number that I receive form REST Parameters the message will not send.
I am trying to take a POST request that then triggers the Twilio Studio to call a store and tell them they have a new online order. They then press Keys to indicate how long the order will take to process and then I send a message to the customer telling them when to pick up their order.
When I keep the {{contact.channel.address}} the same the code runs correctly but when I change this it doesn't work anymore.
Found this link that says it cannot be changed for outbound call but it is possible to edit for send message
Does anyone know can I do this or is this functionality not support at all?
curl -X POST "URL" -d "To=+1xxxxxxxxxx" -d "From=+1xxxxxxxxxx" -d "Parameters={\"orderid\":\"12345\", \"name\":\"Johen\", \"phone\":\"+1xxxxxxxxxx\"}" -u SID:AUTH
Studio Flow

The {{contact.channel.address}} should be equal to the To you pass in when calling the Studio REST Api URL. In your example, "To=+1xxxxxxxxxx".

Related

Trying to return a Twilio call to a Studio Flow

There's a lot going on, but I think I've narrowed it down to something simple. I hope someone can provide any kind of guidance as to what in the world I'm doing wrong.
I've got javascript voice (2.0) working with node.js. I can call inbound and outbound, and I can send a call from a studio flow to a javascript client. This all works. The issue is that when a javascript client user presses "reject" (out of the box example code) or the call isn't answered, it's just dropped. It doesn't return to the studio flow, and I suppose it isn't designed to.
To fix this, I am trying to get the call using the example for client.calls(call sid).update, and I can take the call and issue Say commands and play mp3 files as shown in the example. But when I try to return the call to the studio flow using the webhook url (with or without ?FlowEvent=return appended) it fails. I've tried using the twiml: syntax and providing valid twiml, and I've tried using the url: syntax and providing a url that produces valid redirect twiml (using the echo twimlet).
The URL I'm using is https://webhooks.twilio.com/v1/Accounts/{my_account_sid_here}/Flows/{valid_flow_sid_here}?FlowEvent=return (with and without ?FlowEvent=return at the end)
twiml like this;
<Response><Redirect method="POST">https://webhooks.twilio.com/v1/Accounts/{my_account_sid_here}/Flows/{valid_flow_sid_here}?FlowEvent=return</Redirect></Response> (with and without ?FlowEvent=return at the end)
I'm using the Parent Call Sid (the call sid for the stream never does anything so I assume that isn't the one to use) and the call, when updated, results in a voice message that says "We're sorry, an application error has occurred." I don't know if that is coming from studio or the twilio call processor. If I use the example url with the rick roll mp3 it works.
I've checked the debug messages and they seem to indicate that the flow webhook URL is returning a 400 status code. The documentation says to "To retrieve the Studio Webhook URL in your Studio flow, click the red Trigger widget. The URL starting with https://webhooks.twilio.com/v1/... is the Webhook URL for this Flow" and that's where I got the URL which includes the account sid and flow sid, which I've also checked for correctness.
I'm not sure what to try next.

How do I create an http request from Twilio Studio

I'm technical, but not experienced in coding and could use some help. I need to create an http request from Twilio studio. I am setting up a phone survey for my client and I need to log both voice and number inputs from the call to a database. I already have the database set up externally. It logs responses with an http request from CLI curl. I'm using the following curl request successfully:
curl --data "q=1 -X POST localhost/test.php
When I try to duplicate the same curl request using the http request widget (no http parameters), I only get error 500 back. By the way, I know it's collecting the data correctly with the flow because I've had it collect and then read back to me successfully.
Twilio studio http request.
I have tried adding http parameters instead of putting them in the body as well. Nothing I try works. My guess is that I have a fundamental misunderstanding of http requests and thus can't duplicate it in Twilio.
Any help you could give me would be great! Thank you!
When you add http parameters instead of putting them in the body (see the capture below)
there is a big red "Save" button on bottom left corner, and a gray (hard to see and easy to miss) "Save" link on the right, above the trash bin.
The gray "Save" link needs to be clicked when adding each name/value pair of the parameters.
The red "Save" button is to be clicked at the end when you're done with the http widget.

How to display an interactive message to a channel with a slash command EXCEPT to the person evoking it?

I created an interactive message that gets called via a slash command which gets distributed to the entire channel. Everything works fine. But I can't for the life of me figure out how to limit the message to the entire channel but to the person evoking it. Right now the message goes to everyone including the person that invoked it. If you've ever used /poll, the poll goes out to everyone but the person who created it.
If anyone knows how to do this, can you point me in the right direction?
The response message from a slash command can be only one of two things:
an ephemeral response, which can be seen by the user who issued the command only
an in_channel response, which can be seen by everyone in the channel
There is no feature or switch so that the response message would not be visible to the issuing user.
You can however build a workaround and manually send every user except the one issuing the command an ephemeral message. Here is an outline of how that would work:
Get the list of users of the channel via conversations.members
Send each user an ephemeral message via chat.postEphemeral
There are some significant caveat to this workaround:
You app needs a lot of additional scopes to be allowed to retrieve the member list and send messages (see documentation of those API methods for details)
There is rate limit of about 1 message per second, so it might take quite some time to send those message to all user depending on how big the group is
your slash command needs to respond with 3 seconds. So you will need to implement some fancy multi-threading to be able to send all those messages.
To make that work in private channels you have to work with an additional bot user
That would get you the result you are asking for, but there are some caveats:

Post Slack message as specific user

I'm building a Slack bot with slash commands and I would like to post a message with an attachment as a specific user (specifically, the user that called the slash command).
I know this is possible because the Giphy Slack integration does so when responding to the /giphy [image] command, by responding as the user with a gif image.
I tried using the chat.meMessage method but this does not appear to support attachments.
I tried using the as_user argument in the chat.postMessage method, but this inherits the authenticated user rather than the user that called the slash command.
Responding to the slash command immediately or performing a delayed response (using response_url) doesn't seem to support non-bot responses. If they do, I can't seem to find where it's documented.
In the slash request Slack does provide both user_id and user_name parameters, so I imagine I can make use of those.
I reached out to Slack with this question, and unfortunately at this time it doesn't look like what I'm asking for is possible. The Giphy Slack integration was internally built.
Maybe in the future!

How can I trigger a slash command in Slack every day at a certain time

I want to trigger a slash command in Slack every day at a certain time. Specifically, I want to clear my status every night at midnight.
From the documentation it seems like the only way to do this would be via an Incoming Webhook. However POSTing with the following JSON body just creates a message in Slack /status clear and does not actually run the command.
'{"text":"/status clear"}'
It also posts the message on behalf of the app associated with the webhook, not under my username.
Is there any way to invoke a slash command for my user from outside the official Slack app?
Here is how to execute slash command for your user with an external script.
Use the undocumented API method chat.command execute any slash command, e.g. /status
Use an access token linked to your user account for the API call. One way to get that is to create a so-called "legacy token" with your user.

Resources