I'm trying to set a webhook callback that will be called by Twilio Studio at every stage of a posted message journey and send the activity status back to the webhook I set.
Studio Create Method (What Im currently using)
client.studio \
.v2 \
.flows(TwilioConstants.TWILIOFLOW_PROXY) \
.executions \
.create(
to=f'whatsapp:{user_number}',
from_=f'whatsapp:{TwilioConstants.BASENUMBER}',
parameters={
'name': data.customer.name,
'user_email': data.customer.email}
)
the create method will only accept 3 arguments
create(self, to, from_, parameters=values.unset):
However the messages create method accepts many arguments including the status_callback
client.messages.create
Can anyone tell me how I can get real-time individual WhatsApp message detailed updates sent to a webhook I set myself?
I have tried setting the webhook in:
WhatsApp Sender -> Status callback URL
but that appears to only send very granular data back and only when the user interacts with the message (to be fair I've not let the message timeout yet but possibly this would also be triggered if this happened or an error was encountered)
What I would like is more detailed information being posted back to my webhook such as found in Monitor -> Messaging -> Message Details
Any help with this one would be very much appreciated.
You are right; there is no status callback available in the Studio API. However, you can invoke your "own status callback" by using the Send HTTP Request widget within Studio.
You can either send all the needed parameters in that request or just the execution SID and then use the Execution API to fetch the details about the current step.
Related
I have been trying to work with https://github.com/cordova-sms/cordova-sms-plugin
For Android, it works as expected. Unfortunately, I can't capture the activity for ios and windows. It opens the Messages app (as we know) but it doesn't wait for the Messages response whether it has been sent, canceled, or failed.
It always response success. I am already using async (work on Android).
That's because I can't use the success and error parameters.
It only accepts 3 parameters:
sms.send(number, message, options);
It doesn't accept 5 parameters:
sms.send(number, message, options, success, error);
Error message is:
[ts] Expected 2-3 arguments, but got 5.
(method) SMS.send(phoneNumber: string | string[], message: string, options?: SmsOptions): Promise<any>
Has anyone able to capture Canceled SMS with this or other plugins?
P.S. I tried using other plugins but it can't even send.
According to your error-message (and your tags) you are using the cordova-plugin with ionic-native. In this case you do not need to pass a success/error callback because the ionic-team built a nice wrapper for it so it supports promise callbacks (docs for the .send() method).
To use it you have to modify your code as follows:
sms.send(number, message, options).then(
success => {
console.log(success);
},
error => {
console.log(error);
},
);
Please be aware that the callbacks only work correctly on iOS for this plugin. On the Android platform it will always return success immediately because of limitations of the operating system. For more see this FAQ on their github page.
0
Google changed the policy regarding to SMS access, so the direct reading of incoming SMS is no longer allowed and the associated permissions will be removed (SMS_READ).
Now, it is necessary to use the Android SMS Retriever API your SMS message needs to comply a specific format in order to be intercepted by your app.
In Cordova use this plugin to easily read incoming SMS:
cordova plugin add cordova-plugin-android-sms-retriever Github: https://github.com/diegosiao/cordova-plugin-android-sms-retriever
I need to send a message in slack at a time set in advance.
Is there a way to do it through the Slack API or do I need to have a script running and checking if it's time to send the message and then send it?
You should be able to create a reminder sending a message to #slackbot
The message should be like:
/remind [#someone or #channel] [what] [when]
Here's some examples:
/remind #username to do something in 24 hours
or:
/remind #username to do something at 16:00
You can use this free Slack application to send scheduled and self-destruct messages.
https://timy.website
Sending a scheduled message
/send Happy birthday at 12am
/send Happy birthday in 1h30m
Sending a self-destruct message
/delete Secret message! at 2pm
/delete Secret message! in 3h
You can find more details on the website.
If you just want to send a short message to a user at a given time you can use the build-in reminder. The reminder.add method allows you to specify a date, time, message text and the user to receive the message.
The reminder message will appear in the "Slackbot" channel of the addressed user.
Here is an example on how it would look like:
Update April 2019:
There is now a new API method that allows you to submit message for later sending. Its called chat.scheduleMessage.
You can use the official slack api at endpoint chat.postMessage with a key post_at to have your message scheduled. More information in official slack documentation https://api.slack.com/messaging/scheduling. You can also use 3rd party applications, which are free most of the time, for example https://thetopchat.com/ and schedule your message with commands like, for example:
/delay in 3 hours {your message here}
or
/schedule tomorrow at 3pm {your message here}
The Slack API now provides a dedicated endpoint for that. You will need the chat:write scope and the docs say:
Schedules a message to be sent to a channel.
I just implemented it and works as expected.
You can check the docs here: chat.scheduleMessage
I'm working on embedding a soft phone into a web page that will go into Odoo (web based ERP system). It will allow inbound and outbound calls for employees.
The token expires every hour. So this means the user will have to refresh the page every hour. I could do an http refresh but if the user is on a call when it does the refresh it will knock them off the call.
How do we get around this so we can build a fully working dialer?
Twilio evangelist here.
I'd suggest using JavaScript to do an asynchronous HTTP request to get a new token from your server and then updating the instance of client with it.
Hope that helps.
Another Twilio evangelist here!
You can actually listen for the offline event on the Twilio.Device object. From the documentation:
.offline( handler(device) )
Register a handler function to be called when the offline event is
fired. This is triggered when the connection to Twilio drops or the
device's capability token is invalid/expired. In either of these
scenarios, the device cannot receive incoming connections or make
outgoing connections. If the token expires during an active connection
the offline event handler will be called, but the connection will not
be terminated. In this situation you will have to call
Twilio.Device.setup() with a valid token before attempting or
receiving the next connection.
So you want something like:
Twilio.Device.offline(function(device) {
fetchTokenFromServer(function(token) {
device.setup(token);
});
});
where fetchTokenFromServer makes the HTTP request that Devin suggested in his answer.
Let me know if this helps.
I just ran into this issue so hopefully my solution can help you and others.
I was using twilio.js v1.3 and tried implementing my offline callback like #philnash recommended, but kept getting the error device.setup is not a function. I then tried using Twilio.Device.setup(newToken) and was able to get the capability token refreshed but also ended up getting a new error: Cannot read property 'setToken' of undefined.
I ended up having to use twilio.js v1.4 to make the error go away. My working solution looks like this:
Twilio.Device.offline(function(device) {
$.ajax(urlToGetNewToken, type: 'get').done(function(newToken) {
Twilio.Device.setup(newToken)
})
})
I'm using sinch and I've gotten the client to work by registering a user, but I can't send a message. When I click my send button, nothing happens. The required methods that need to be implemented, such as messageFailed(), messageDelivered(), etc. are not being called either. Does anyone know why?
Have you registered the one more user? Can you enable logging and share the full log output.
See comment below, user tried to send message to self
I am trying to code a simple irc bot that detects if a word is inside a chat message and then saves that message to a file. I have the correct 'on text' event set up, but I don't know how to access the message that was sent so I can save it.
on *:TEXT:*txt*:#:
{
var %message $msg
writeini Log.ini Message value %message
}
$msg is clearly wrong. Is there an identifier to have my bot access the messages in the chat, or is there a completely different way to do this? I can't seem to find anything online about this either.