I am trying to use the Twilio API and I would like to use the message content as a filter. So ideallay I would like to make a request like https://api.twilio.com/2010-04-01/Accounts/AccSID/Messages.json?body="test" and it would include all the messages that have the word "test" in their body whether inbound or outbound messages.
In Twilio docs I could only find filtering messages by date sent. Can the above use case be achieved with Twilio?
There isn't a parameter to filter message body content using the /Messages resource. You can look at the BulkExport API to export the messages to your datastore or capture the logs locally from your Application server upon origination and termination of the message responses and store those in your datastore for later filtering based on your DB logic.
BulkExport API Overview
Best Practices for SMS Message Logging
Related
I want to send different messages to multiple users at once. I read the article here: https://www.twilio.com/blog/send-bulk-sms-twilio-node-js-html but it mentions nothing about sending customized messages. The only difference in my messages is the user's name.
The best solution I can think of is to create x number of API calls to send messages to x numbers. I believe that's going to be time taking. Is it possible to do it with one API call?
Twilio developer evangelist, and author of that post, here.
You are right, there is not currently a Twilio service that allows you to send bulk messages with customised messages with one single API call. You will have to make an API call to the messages resource for each message you want to send.
When sending messages in bulk, I recommend you read and understand this article on Twilio rate limits and message queues. That will ensure you are successful in sending your messages.
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
i am working on a slack app (scope including bot and incoming webhooks). I can send message to a defined channel but i don't know how to stop using the "&channel=" parameter and just send messages to listening channels. By listening i mean, when the app is installed, user is asked where to post (channel or dm has to be chosen).
String postUrl = "https://slack.com/api/chat.postMessage?token=" + botAccessToken + "&as_user=false&channel=%23community&text=testing&username=CommunityQ";
Any hints would be useful.
I think you can't: According to the official Slack API documentation it is not possible to send messages to all/multiple listening channels:
Incoming webhooks output to a default channel and can only send
messages to a single channel at a time. You can override a custom
integration's configured channel by specifying the channel field in
your JSON payload.
I interpret this as "there is always exactly one channel your message is sent to"
Furthermore, Slack restricts this channel override feature for Slack apps:
You cannot override the default username, icon, or channel for
incoming webhooks attached to Slack apps.
I think there is a slight confusion here. I am not sure what the "incoming webhook" scope does that the "bot" scope cannot do. Here's how I see things
Either you want a lightweight, low-permission app that posts in one channel, and you'd use the incoming webhook scope
Or you want an app that can ask questions to the users, like which channels they'd like to have updated posted to, process answers, etc. Then you'd use the bot scope, and the bot can post in any public channel
If you give a bit more details in what you want to achieve we can perhaps help you better
If you want a more dynamic approach on sending messages into any channel I would suggest to user the API method chat.postMessage instead of an incoming webhook.
The API method can post messages into any channel (including private channels, DMs) as long as your token as access to it.
As Michael mentioned in his answer, it is not possible to post to multiple channels at the same time. You have to look through them and do multiple requests.
I am using Copilot API of twillio to send sms. so i am able to send sms to end user. Now if user reply to that sms, i am receiving the callback (PHP Script). Using that callback URL, i am able to get the reply message.
Now i want to do is, i am trying to find a relation between sent and received(which end user reply) message. so i can then forward the reply message to their sender.
I will have UI like below, where user enter the message and number where he wants to receive reply.
But the problem is i am not able to find relation between send/receive message.
Any advice will be helpful.
Twilio developer evangelist here.
Other than storing the information on your server upon sending/receiving a message, you could make use of the cookies stored at Twilio.
When Twilio makes a request to your server and it returns a cookie (a Set-Cookie HTTP response header), Twilio stores this cookie and associates it with the From and To numbers for the incoming call or SMS message.
A little caveat to this is the fact that this cookie is only stored for four hours, so unless that works for you, I'd suggest using the from & the to as composite keys to find a relation.
Hope this helps you
Twilio has a nice SMS message log resource that I can query via the REST API. Do developers need to write a garbage collection service to delete old SMS messages? Or is there some retention policy?
Otherwise - will I be charged? (I see MMS storage needs to be deleted manaully)
Twilio evangelist here.
Twilio will only charge you for storing pictures on the Media Instance Resource. Your SMS messages will stay there, and you can query them via the API whenever.
Your messages also stay for as long as you own the number.