How do I retrieve the sender number when using Twilio's messaging services with Copilot enabled? - ruby

I have a Twilio messaging service with Copilot and the sticky sender feature enabled.
I would like to view the phone number that Copilot assigns to my recipients when I send them a message.
With the Ruby client, I get a MessageContext object when I send a message, but it only has the
messaging service SID - the from method returns nil.
Currently, this is how I'm sending messages:
def send(from, to, message)
client = Twilio::REST::Client.new(ACCOUNT_SID, AUTH_TOKEN)
client.api.account.messages.create(
body: message,
messaging_service_sid: from,
to: to,
status_callback: BASE_URL + '/sms_status/status',
)
end

Twilio developer evangelist here.
I'm not sure, but you might not have the phone number at the time you make the API request using a messaging service. This request really just queues up the message to be sent.
I would check the message object once it has been sent. You have a status callback URL setup, so you should be able to either inspect the parameters sent to that URL or look up the message from the API using its SID and then get the number that was used.

Related

How to see/track the exact HTTP response (code and message) that an Eventgrid webhook endpoint receives?

I have a Webhook Eventgrid subscription. I do not have access to the webhook logs or implementation.
Apparently ,Eventgrid receives HTTP code other than success from the webhook, but I do not have any detail visibility to that.
How can I see the exact HTTP interaction (Response message, HTTP Code) for the EventGrid WebHook Bad Requests like the ones pointed below?
You need to configure the dead letter on your event grid subscription as documented here.
Once the events are not delivered and dead letter now you can review the lastDeliveryOutcome property on the dead letter events to know what was the reason the event was not delivered to the configured endpoint.
You cannot find the reason for each request at your end as the event may be delivered at a later point in time once it is retried.

In a group chat, should the new message event (websocket) be sent by the client or the API?

I have a doubt, in a group chat system that has a database with a rest API, who should issue the event of a new message?
The client or the endpoint to create the new message?
For example: X user sends a message to group Y, then uses the api endpoint api.com/message-create and that endpoint emits the message-create event through websocket
Example 2: X user sends a message to group Y, then uses the api api.com/message-create endpoint and the endpoint does not emit the message-create event, but was emitted when the user pressed the send message button
I still don't quite understand if it would occupy more websocket channels to achieve that, if a global one is enough, etc.
The server should be responsible for communication logic. So your first example is better.
But: why do you use two communication channels for sending an creating messages?
If you use websocket, you don't need create a message from a client by using additional rest endpoint.
This approach is prone to errors. For example if the client will loose network connection after sending message through websocket and before executing call to the REST endpoint?
The message will not be stored in a database.
Your flow should looks as follows:
User clicks the send button.
Message is send through the websocket.
Message is stored in the database asynchronously (you can do it directly from communication server, or use rest endpoint)
Emit "new message" event to the group.

Use TwiMl templates for sending outbound sms

I am new to Twilio. We have a requirement in the project as follow -
Send an outbound SMS to a given number. The message body is static text and should be defined using a template on Twilio(TwiML), so that client can change the message body anytime without making any changes in the backend application.
I have gone through the Twilio documentation to understand how to use TwiML, but couldn't find any document or article which explains how to use TwiML for sending an outbound SMS. Currently I am using following code to send a SMS and the message is configured in the Spring Boot application.properties file.
Message message = Message.creator(new PhoneNumber(phoneNumber),
new PhoneNumber(fromPhoneNumber),
messageBody).setStatusCallback(URI.create(callBackUrl)).create();
Does anyone know how to use TwiML template to send an outbound SMS. Can someone help me to solve this problem. Thank you.
What is Twiml?
Twiml is instructions for Twilio, how to respond to an incoming phone call,SMS, etc...
What is Twiml
It is not for outbound actions.
To initiate an SMS , you should use the Twilio api which is what you are doing when you use the sdk such as Message.creator

Twilio client: Outbound call isn't showing agent/caller name in 'From' field on call logs

I'm making an outbound call from my Twilio client to make outbound web browser calls. The calls are successfuly made and are fine, but...
Unfortunately I'm unable to see the agent/client name in your logs. I am currently using the agent/client name of 'Andy' but in Twilio's call logs it's showing the 'From' field as anonymous.
I have made a few changes to the JavaScript SDK and have added the following ''//CLIENT NAME clientName: 'Andy'' in the 'params' variable but this hasn't made a difference and the from field is still showing up as Anonymous in Twilio's call logs when I make an outbound call using the browser client.
How do I make this work? :(
Here is my code:
// Bind button to make call
document.getElementById('button-call').onclick = function () {
// get the phone number to connect the call to
var params = {
//CLIENT NAME
clientName: 'Andy',
//PARAMETERS THAT WILL BE SENT THROUGH TO TWILIO
To: document.getElementById('customer-number').value,
//THIS IS CUSTOMER CALLER ID WE'RE PASSING TO THE OUTGOING TWIML AS THE CALLER ID TO USE FOR OUTGOING CALL
CallerID: document.getElementById('source-number').value
};
console.log('Calling ' + params.To + '...');
Twilio.Device.connect(params);
};
Twilio developer evangelist here.
The parameters you pass into Twilio.Device.connect are not recorded by Twilio, but they are sent on as parameters to the URL you set as your application URL.
Client names are actually only required for incoming calls that are routed to a client. If you were to setup a client for outgoing calls only you need not setup a name. As such, client names are not captured by Twilio in the call logs.
If you need to track which clients are making calls you can do so within your own application by reading the clientName that you set in Twilio.Device.connect from the webhook parameters and associating it with the CallSid (also available in the webhook parameters).

Messaging in xmatters through API call

I am trying to message or send alert in Xmatters using API in postman. This call was successful and an Id also generated in response, but the message was not reached to the Targeted person.When I did it from UI the mail was sent to the targeted person.
What was the endpoint of your API? Were you targeting an inbound integration endpoint (api/integration/functions/UUID/triggers), or the form endpoint (/reapi/yyy-mm-ddd/forms/UUID/triggers)? If you target the inbound integration endpoint, you will get a UUID returned while the form endpoint will return an event ID.
If an event was created, you will see an entry in the reports tab of the UI for that event and it will have any errors around notifying users.

Resources