Twilio Update Outgoing caller ID - ruby

Trying to update an outgoing caller ID, but running into following error:
*** Twilio::REST::RestError Exception: Unable to fetch record: The requested resource /2010-04-01/Accounts/AC...../OutgoingCallerIds/CA......json was not found
I'm following the docs on Twilio's website:
https://www.twilio.com/docs/api/voice/outgoing-caller-ids#get-outgoing-caller-id-details
#caller_id = #client.account
.outgoing_caller_ids('PNe905d7e6b410746a0fb08c57e5a186f3')
.fetch
What string do I need to pass to .outgoing_caller_ids?

Twilio developer evangelist here.
Outgoing caller IDs are verified numbers that you can use as a caller ID when you're making calls from your account.
I was able to fetch an outgoing caller ID with the following code:
sid = client.outgoing_caller_ids.list.first.sid
caller_id = client.outgoing_caller_ids(sid).fetch
My guess is that you are actually looking for the Incoming Phone Numbers resource, which is the resource you can use to fetch and update numbers that you bought on the Twilio platform.
You can call that with the number SID like this:
client.incoming_phone_numbers(sid).fetch
Let me know if that helps.

Related

RingCentral Main Company Number SMS `Phone number doesn't belong to extension` error

I tried to send SMS and listed the from as our Main Company Number but it would not go out. Said Phone number doesn't belong to extension per the error below. The RC account I am using for running my API calls does not have a phone line/number assigned.
Do I have to be logged in with the account that matches the from phone number?
{
"errorCode": "FeatureNotAvailable",
"message": "Phone number doesn't belong to extension",
"errors": [
{
"errorCode": "MSG-304",
"message": "Phone number doesn't belong to extension"
}
]
}
You can send SMS from the Main Company Number for a single user or multiple users using the following approaches:
Scenario 1: Send and Respond using a single user
In-order to send SMS from the main company number:
Set the Operator Extension
Authorize using the Operator Extension
Send SMS using the Main Company Number
Operator Extension: When a caller presses 0 (zero) or does not enter an extension number, the system connects the call to the designated operator extension by default. An Administrator can configure the operator extension
to have different call handling rules.
Scenario 2: Send and Respond using Multiple Users
In-order to send and SMS from Main Company Number and respond to it using multiple users, set up a call-queue and configure the operator extension to point to the Call Queue.
Create a Call-Queue and assign a password to it.
Set the Operator Extension to point to Call Queue.
Authorize using the Operator Extension ( Call Queue )
Send SMS using the Main Company Number
More info is available here:
https://devcommunity.ringcentral.com/ringcentraldev/topics/how-to-send-sms-from-the-main-company-number
To verify the numbers your user extension can send SMS from, call the following endpoint:
GET /restapi/v1.0/account/{accountId}/extension/{extensionId}/phone-number
This will return an array of phone numbers. Check the features property. The ones that can be used will have the SMSSender and/or MMSSender features. More info on this is available in the Developer Guide:
http://ringcentral-api-docs.readthedocs.io/en/latest/messages_sms-and-pager/#listing-valid-sms-sending-numbers

Twilio SMS sent from +12345

I am sending SMS using Twilio Node (http://twilio.github.io/twilio-node/).
In the from field I've set the number that Twilio gave me, yet when I receive the SMS it shows as +1 (234) 5.
The only thing I can think of is that I am using the trial account, but their FAQ doesn't say anything about this...
https://www.twilio.com/help/faq/twilio-basics/how-does-twilios-free-trial-work
Code snippet:
// Require and initialize the Twilio module with your credentials
var client = require('twilio')('A-FAKE-8cc', 'b53090-FAKE-6808');
// Send an SMS message
client.sendSms({
to:'+' + to,
from: '+15734XXXXXX',
body: 'Your code is ' + code
}, function(err, responseData) {
if (err) {
console.log(err);
} else {
console.log(responseData.from);
console.log(responseData.body);
}
}
);
Here is another piece of info: my twilio number is in the US, while my destination is in Israel - does it matter? Also, when I verified my number I received the code from this +12345 as well.
Confirming my suspicion: I've just verified a US number this time, and it showed the correct number (both from my app and from twilio).
Hey to be very honest your location doesn't matter to have a call on the Twilio platform apart from that if you want to have an upgraded account i'll suggest you to apply for Github's student developer program you'll get 50$ from that and you can buy some virtual numbers from that.
And to successfully make calls i am linking a repository which will help you in sending messages as well as calls over the internet.Getting started with Twilio at MLH INIT

How would I design this scenario in Twilio?

I'm working on a YRS 2013 project and would like to use Twilio. I already have a Twilio account set up with over $100 worth of funds on it. I am working on a project which uses an external API and finds events near a location and date. The project is written in Ruby using Sinatra (which is going to be deployed to Heroku).
I am wondering whether you guys could guide me on how to approach this scenario: a user texts to the number of my Twilio account (the message would contain the location and date data), we process the body of that sms, and send back the results to the number that asked for them. I'm not sure where to start; for example if Twilio would handle some of that task or I would just use Twilio's API and do checking for smss and returning the results. I thinking about not using a database.
Could you guide me on how to approach this task?
I need to present the project on Friday; so I'm on a tight deadline! Thanks for our help.
They have some great documentation on how to do most of this.
When you receive a text you should parse it into the format you need
Put it into your existing project and when it returns the event or events in the area you need to check how long the string is due to a constraint that twilio has of restricting messages to 160 characters or less.
Ensure that you split the message elegantly and not in the middle of an event. If you were returned "Boston Celtics Game", "The Nut Cracker Play". you want to make sure that if both events cannot be put in one message that the first message says "Boston Celtics Game, Another text coming in 1 second" Or something similar.
In order to receive a text message from a mobile device, you'll have to expose an endpoint that is reachable by Twilio. Here is an example
class ReceiveTextController < ActionController
def index
# let's pretend that we've mapped this action to
# http://localhost:3000/sms in the routes.rb file
message_body = params["Body"]
from_number = params["From"]
SMSLogger.log_text_message from_number, message_body
end
end
In this example, the index action receives a POST from Twilio. It grabs the message body, and the phone number of the sender and logs it. Retrieving the information from the Twilio POST is as simple as looking at the params hash
{
"AccountSid"=>"asdf876a87f87a6sdf876876asd8f76a8sdf595asdD",
"Body"=> body,
"ToZip"=>"94949",
"FromState"=>"MI",
"ToCity"=>"NOVATO",
"SmsSid"=>"asd8676585a78sd5f548a64sd4f64a467sg4g858",
"ToState"=>"CA",
"To"=>"5555992673",
"ToCountry"=>"US",
"FromCountry"=>"US",
"SmsMessageSid"=>"hjk87h9j8k79hj8k7h97j7k9hj8k7",
"ApiVersion"=>"2008-08-01",
"FromCity"=>"GRAND RAPIDS",
"SmsStatus"=>"received",
"From"=>"5555992673",
"FromZip"=>"49507"
}
Source

Twilio: Outputting the SID of a conference

When you dial a phone number through the Twilio API, the platform passes the call's unique 34 character SID to your application as a parameter.
For example, when the Twiml I send to the Twilio platform dials a call through a < Dial > verb, I can easily do:
puts params['CallSid']
#incoming_Cid = params['CallSid']
Thus, the Sid is saved as a variable for later use. However, I don't know what the name of the parameter passed to your application to find the < Conference > Sid is.
Can anyone who knows please clarify?
You can retrieve info about a Conference by filtering the Conferences list endpoint by the Conference friendly name. For example if your Conference is named "foo" you can do
GET /2010-04-01/Accounts/AC.../Conferences?FriendlyName=foo
to retrieve a conference.
There is an example in Ruby here:
http://www.twilio.com/docs/api/rest/conference#list-get-example-2

How Can I Use xmpp4r To Detect The Online/Offline Status Of A Given Jabber ID?

What is the proper xmpp4r way to know if a given contact is online before sending them a message?
Can you post sample xmpp4r code for doing this?
Here is my use case:
If contact online, send :normal message
Else, email contact
Here are things I have working code for:
Send messages of various types
Get a roster/contact list
Register a call back to detect changes in presence
However, I can't find a place that directly addresses a work flow like this:
Loop through each JID in your roster
If jid.is_online? == true, send IM
Else, send email
I've read that you should send a JID a message of type :headline and if that fails, you know the user is offline. In my tests, if the user is ONLINE, they'll receive a message of type headline. This is suboptimal, as users should only receive messages to read, not noise to determine online status.
I've read that on sign on, all of your contacts will bounce a presence status back at you, and that status is the sole indication that they are online - assuming that there isn't a disconnect or presence change you've yet to receive. So you should register a presence call back, record the initial users who ping you back, and then add or remove from the list based on your running roster presence callback.
If this is truly the way to do it:
Can I get some example code of how to collect all the "I'm here" presence confirmations on sign on via xmpp4r?
Why, oh why, was xmpp designed this way and why is this better than offering an "is_online_and_available" method?
So the answer here is adding a message call back and checking inside the block for the type:
m = Message.new(to, body)
cl.send(m)
cl.add_message_callback do |m|
if m.type == :error
puts "type: #{m.type}"
else
puts "not an error"
end
end
This requires threading as you have to be listening for the response.

Resources