Twilio Recording after call initiated - rest

I'm currently using the Twilio API in order to implement a call-recording feature for my app. I'm wondering whether it is possible to accomplish the following scenario.
Person A calls Person B, connection between the two is established
Person A would like to start recording the phone call and pushes a recording button
Call ends, Person A receives recording
I have tried the following:
Connect the two users so that they can talk to each other (Successful)
Use the REST API to modify the live call and put the TwiML record verb.(ref https://www.twilio.com/docs/api/rest/change-call-state#example-1)
Been stuck on step 2, whenever I try to redirect at all it just disconnects the call. Is there a proper way to inject TwiML messages while the call is going on using the rest API?

Related

Convert a text to voice recording and then play it after calling a phone number on Flutter

I'm trying to make an app which gets the location of a user and then call a number(pre-selected by user) to send a recorded voice message, like say "Location is {longitude} degrees, {latitude} degrees" but I can't find anything to do the same I found Twilio on some searching but in the Flutter package twilio_voice I can't find anything to do what I want.
So my question is can this be done in Twilio and if not what else I can do?
(Edit :I have figured out the part to fetch the user location and just display it on the screen, the part that remains is to convert this to speech and play on call)
You can achieve this with Twilio, however you will need a server from which to make the requests to the Twilio API. To make an API call to Twilio you need to use your Account SID and Auth Token and if you were to embed those within your Flutter application then a malicious user would be able to decompile your app, steal your credentials and abuse your account.
So, the best way is to build a server-side application that can make the API calls on behalf of your app and then send the relevant data (the location, in this case) from your mobile app to the server application.
On the server-side application, once you receive the location data you can generate a call by calling on the Twilio calls resource and pass the number you want to call, the number you are calling from and the TwiML you want to execute on the call. TwiML tells Twilio what to do on a call, and in this case you can direct Twilio to <Say> the message with the location.
I see you've asked python questions in the past, so here's a quick example of calling the Twilio API to create a call in python:
import os
from twilio.rest import Client
# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
call = client.calls.create(
twiml='<Response><Say>Location is {longitude} degrees, {latitude} degrees</Say></Response>',
to=TO_NUMBER,
from_=YOUR_TWILIO_NUMBER
)
print(call.sid)
You need to divide your problem into smaller subproblems and test if the native OS (Android / iOS) allows you this:
Fetching current user location
Create an audio file with a text-to-audio speech generator
Research if it's possible to make calls programmatically (this might be tricky)
Make a phone call
Research if it's possible to play audio file while in call
Play an audio file on speaker while incall

Sending React Native Notification on database update?

I have an AWS Postgres database, an API layer, and a React Native application. One user is trying to communicate with another (and this will be stored in the db) I want to let the intended user know that a message awaits them with a notification. I'm not using expo. I've looked at using OneSignal but the functionality seems limited in this aspect (unless I'm missing something) I've prefer to use React Native Local notifications. Does anybody know how to achieve this with either OneSignal or RNLC?
You want 2 users to communicate with each other, and via a notification to let them know they have a new message. You can send push notifications directly to a user by using the player id and our REST API. The player id will target only the user the notification was meant to be sent to.
https://documentation.onesignal.com/reference/create-notification

Callout from trigger without using Future annotation

At this moment I'm calling a #future method X from the Account_after_update trigger. I have to use #future annotation because X makes an external site call (just to notify account is updated). It's working fine.
But for some reasons (please don't ask why) I have to remove #future annotation.
And of course it will be impossible to make HTTP request from the X method (Salesforce restriction).
Is there a way how to notify external site about account updating (and send an account ID) without using of #furure annotation? Or even without a trigger? Probably something like subscription to account_updated event.
You can use outbound messages which can send a soap request to an endpoint using workflow, or you can use the streaming api where you can create push topics to send push notifications to subscribers. Of the two options outbound messages is simplest if your endpoint supports soap.
You can try creating background jobs to do the work for you. hope you find the solution here

Possibility on implementating sending Direct message using Twitter API

I would like to know how to send Multiple Direct message on Twitter. In my app using twitter api, i am able to send Direct message to one( Using DM Syntax ).
Currently i can see some tools like MultiDM website allows to send multiple Direct messages at a time.
So is that possible from iPhone's twitter api?
Also i wonder how the MultiDM website works as such
Pls let me know
In twitter API there is only 1 method of sending a DM: https://dev.twitter.com/docs/api/1/post/direct_messages/new
If you need to send multiple DM's - just call this method multiple times (with different recipient)
Yes you cant send DM to more than one user in a single call of the API.
If you want to send DM to multiple users, just make an array of all users id or screen name and in a loop send direct messages to All through the below API...
https://dev.twitter.com/docs/api/1/post/direct_messages/new

Call transfers, hold and conference calls

In the process of building an operator application in C# I have encountered some problems. They all stem from the fact that the operator isn't actually a phone. So doing things like transfer a call (a BYE then REFER), or placing a call on hold (send another INVITE as a=recvonly) are easy for phones to do because they already hold state information about the call dialog from the initial handshake.
Is it possible to send INVITEs on behalf of another phone to get them into conference? Is it possible to send INVITEs on behalf of another phone to get them into hold?
Well, if you are using Asterisk I'd recommend looking into Asterisk Manager Interface and not deal with SIP protocol directly. It provides methods to create/transfer/hangup calls,monitor,etc, and everything else you might need.