Asterisk inbound/outbound SIP trunk with Twilio - voip

I'm trying to use Twilio as my SIP trunk for an Asterisk install. I can get Google Voice to work, but can't get Twilio to work. Here are the SIP trunk settings. What am I missing?
Outgoing Settings --
Trunk name: Twilio-Out<br
PEER Details:<br
username=\*\*\*username\*\*\*<br
type=peer<br
secret=\*\*\*password\*\*\*<br
context=from-trunk<br
host=\*\*\*name\*\*\*.sip.twilio.com
Incoming Settings --
USER Context: Twilio-In<br
USER Details:<br
type=user<br
context=from-trunk<br
secret=\*\*\*password\*\*\*<br
Registration --
Register String: [empty]

(If you have access to the asterisk configuration file)
Try adding following section in the sip.conf file
register => NNNN#XXXX.sip.us1.twilio.com:YYYY:XXXX.sip.us1.twilio.com:5060
[phone]
host=XXXX.sip.us1.twilio.com
secret=YYYY
defaultuser=NNNN
fromuser=NNNN
fromdomain=XXXX.sip.us1.twilio.com
insecure=port,invite
type=peer
allow=gsm,ulaw,alaw
context=KKKK
tos_sip=cs3
tos_audio=ef
Here,
XXXX is subaccount/acccount name on the twilio. If you are not usa, update the twilio host and domain server near your location.
YYYY is the password.
NNNN is credential you created in twilio under the subaccount.
KKKK is the name of the dialplan section which you want to get executed when you get incoming calls.
Also, you need to define the dialplan in the extensions.conf file.

Related

Incoming webhook trigger for Azure Devops pipeline : "Cannot find webhook for the given webHookId"

I try to setup a incoming webhook in a project to trigger a yaml pipeline.
Setup service connection with incoming webhook.
Added yaml snippet to pipeline like this:
resources:
webhooks:
- webhook: testtrigger ### Webhook alias
connection: testconnection ### Incoming webhook service connection
When calling the url via curl : curl -X POST 'https://dev.azure.com/<my org>/_apis/public/distributedtask/webhooks/testtrigger?api-version=6.0-preview' -d '{ "tags": {} }' -H "Content-Type: application/json", I always get the error message :
{"$id":"1","innerException":null,"message":"Cannot find webhook for the given webHookId testtrigger. Try enabling CD trigger for this artifact.","typeName":"Microsoft.TeamFoundation.DistributedTask.Pipelines.Artifacts.WebHooks.WebHookException, Microsoft.TeamFoundation.DistributedTask.Orchestration.Server","typeKey":"WebHookException","errorCode":0,"eventId":3000}
Tried with different names on triggers/connection but nothing worked.
Any ideas what I am missing ?
Echoing #FrankBaumfalk's comment, you need to ensure the pipeline's default branch is the same as the one that youre developing on. (You may be like me, developing and testing this yaml on a branch of the same repo it is built for.)
To indicate your default branch:
Edit yer Pipeline
Choose Triggers from the kabob menu
Choose the YAML tab, see below 👇
Notice the default branch field; save
Also, yes the error referring to webHookId is the WebHook Name in the Incoming WebHook in Services Connections. Yay consistent naming.
Based on my test, I could reproduce this issue.
The root cause of this issue is that you are using the incorrect webhook name.
To find the correct webhook name, you could navigate to Project Settings -> Service Connection -> testconnection incoming webhook.
Or you could go to the target Webhook and check the request url:
https://dev.azure.com/<ADO Organization>/_apis/public/distributedtask/webhooks/<WebHook Name>?api-version=6.0-preview
The testtrigger in yaml pipeline is the name of the webhook resource. This is a custom name instead of the correct webhook name.

How to list call recordings in Nexmo?

I'm working on a voice assistant with Nexmo.
I use Node-RED to build the NCCO object including a record node.
In the provided tutorials by Nexmo, e.g.
Build Your Own Voicemail With Node-RED and the Nexmo Voice API
the directly download the recording to the local machine.
In my case, don't want to immediately download the audio file via node-red but let Nexmo store my audios and download them all together later through e.g. a Python script.
In the docs it says that "NOTE: After your recording is complete, it is stored by Nexmo for 30 days before being automatically deleted".
Unfortunately, I can't find any reference about where the audios are stored in my Nexmo account and how to list all recordings/recording urls of a Nexmo application.
Thank you for any help.
Nina
Currently there’s no way to get the recordings as a list from Nexmo.
What you could do instead is, capture the API response from the recording webhook and log it.
Then later on when you’re ready to download them, read it back to a get recording node.
If you connect a debug node into the /recording webhook, you can see the structure of the message object.
payload: object
start_time: "2020-03-04T13:06:40Z"
recording_url: "https://api.nexmo.com/v1/files/516f74a8-abcd-4270-b553-2582650a2e5a"
size: 26478
recording_uuid: "dbd3cb68-0a3a-4c89-bc2d-7c38abd2c497"
end_time: "2020-03-04T13:06:47Z"
conversation_uuid: "CON-93ef5eef-gg92-49ae-9e01-f3c782390dd9"
timestamp: "2020-03-04T13:06:47.733Z"
You’ll need the recording_url to download a recording, but it’s good to keep the conversation_uuid handy, as you can lookup the FROM and TO numbers based on this.
I'm leaving a possible solution with Google Sheets below, as a replacement for the /recording webhook. Import it from clipboard into your editor and see the comment node for instructions :)
[{"id":"9198a326.cfb3e","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"49dc7444.625ff4","type":"http in","z":"9198a326.cfb3e","name":"","url":"/record","method":"post","upload":false,"swaggerDoc":"","x":210,"y":380,"wires":[["21594561.f44c1a","47021216.a25afc","dc814f00.17fa7"]]},{"id":"47021216.a25afc","type":"http response","z":"9198a326.cfb3e","name":"","statusCode":"","headers":{},"x":610,"y":380,"wires":[]},{"id":"5371302c.ee3688","type":"getrecording","z":"9198a326.cfb3e","creds":"10de89c6.d1db3e","filename":"recordings/{{msg.payload.from}}_{{msg.payload.timestamp}}.mp3","x":1260,"y":580,"wires":[["6d03a7ed.2a6d7","38dd6acf.b46cae"]]},{"id":"21594561.f44c1a","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":450,"y":320,"wires":[]},{"id":"bcb08110.c2f7c","type":"e-mail","z":"9198a326.cfb3e","server":"smtp.gmail.com","port":"465","secure":true,"tls":true,"name":"","dname":"","x":1690,"y":580,"wires":[]},{"id":"6d03a7ed.2a6d7","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1490,"y":500,"wires":[]},{"id":"38dd6acf.b46cae","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"'Voicemail from ' & msg.req.query.from","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":580,"wires":[["bcb08110.c2f7c"]]},{"id":"c8fadcb1.13aca","type":"inject","z":"9198a326.cfb3e","name":"Download/Send recordings in email","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":280,"y":580,"wires":[["af254a75.791888"]]},{"id":"f9706ea5.ea66","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"start_time\": (msg.payload)[0],\t \"recording_url\": (msg.payload)[1],\t \"size\": (msg.payload)[2],\t \"recording_uuid\": (msg.payload)[3],\t \"end_time\": (msg.payload)[4],\t \"conversation_uuid\": (msg.payload)[5],\t \"timestamp\": (msg.payload)[6],\t \"from\": (msg.payload)[7]\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1060,"y":580,"wires":[["5371302c.ee3688"]]},{"id":"9f017b25.db6fe8","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":440,"wires":[]},{"id":"dc814f00.17fa7","type":"change","z":"9198a326.cfb3e","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"[payload.start_time, payload.recording_url, payload.size, payload.recording_uuid, payload.end_time, payload.conversation_uuid, payload.timestamp, req.query.from]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":440,"wires":[["c8118876.f668e"]]},{"id":"521189f7.2f6d8","type":"debug","z":"9198a326.cfb3e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":760,"wires":[]},{"id":"deba2a63.a4f4d","type":"split","z":"9198a326.cfb3e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":830,"y":580,"wires":[["f9706ea5.ea66"]]},{"id":"c8118876.f668e","type":"GSheet","z":"9198a326.cfb3e","creds":"90e07aa9.34a6","method":"append","action":"","sheet":"1mmXhj40aeSooxmtku3ma4auLyrHhJO8xCSQsklZ1_BU","cells":"Sheet4!A1","name":"","x":730,"y":440,"wires":[["9f017b25.db6fe8"]]},{"id":"af254a75.791888","type":"GSheet","z":"9198a326.cfb3e","creds":"bd7b95fd.c3dee8","method":"get","action":"","sheet":"1mmXhj40aeSooxmtku3ma4auLyrHhJO8xCSQsklZ1_BU","cells":"Sheet4!A:H","name":"","x":610,"y":580,"wires":[["521189f7.2f6d8","deba2a63.a4f4d"]]},{"id":"335f8e96.7242ba","type":"comment","z":"9198a326.cfb3e","name":"📖 Instructions","info":"1. Install `node-red-contrib-google-sheets` package and restart Node-RED.\n2. Add _creds_, _SpreadsheetID_ and _Cells_ in the **GSheet** nodes \n3. Add your Nexmo credentials in the **Get Recording** node\n4. Configure **email** node or add download functionality","x":220,"y":180,"wires":[]},{"id":"10de89c6.d1db3e","type":"nexmovoiceapp","z":"","name":"New Voice App"},{"id":"90e07aa9.34a6","type":"gauth","z":"9198a326.cfb3e"}]

Send email via GMail SMTP in REBOL 2

I am new to REBOL. People blogging about how great REBOL is used sending an email as an example, similar to this example from the "send" documentation:
send luke#rebol.com "Testing REBOL Function Summary"
having read how easy and convenient it is to do this, I excitedly tried to send myself a test email via my GMail account.
I looked at the official GMail help for SMTP/POP to get the relevant SMTP/POP server names:
https://support.google.com/mail/answer/7104828?hl=en
And here is how far the "send" and "set-net" documentation got me:
>> set-net [ myrealusername#gmail.com smtp.gmail.com pop.gmail.com ]
>> send myrealusername#gmail.com "Hello me!"
connecting to: smtp.gmail.com
** Access Error: Cannot connect to smtp.gmail.com
** Where: open-proto
** Near: smtp-port: open [scheme: 'esmtp]
either only
On reflection, of course it didn't work; I told REBOL nothing about wanting to use SSL/TLS, the relevant port numbers, or my GMail password. It must need all of the above to actually send an email.
So how do I do it?
I modified the protocols some years ago to work with gmail. I hope that they still work.
You'll need to run both the prot-ssmtp.r and prot-ssend.r, and you'll need a version of rebol2 which supports ssl. This is either a free view build, or a paid core build.
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssmtp.r
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssend.r
Now, you can either set the user and password manually:
system/schemes/esmtp/user: "username"
system/schemes/esmtp/pass: "password"
or, when the script runs the very first time, you will be asked the values so that they can be set for that rebol instance. The prot-ssmtp uses port 465 but you can modify that if it's no longer correct.
And then it should be as straight forward after setting set-net as:
ssend email#someon.com "This is my message"
Note that we now have email on ren-c which is the open source fork of rebol3.

Accessing local https service from stripe webhook

I am integrating a payment system using Stripe. In the process, I need to test the webhooks in my local dev. machine before I ship it to QA. I have tried the following,
Ultrahook: however when starting the ultrahook it said, authenticated <myaccount>, but did not give any "Forwarding activated..." message. When I tried to access the url from stripe or web, it did not work. Details below,
local url: https : //localhost/xxx/yyy/zzz
ultrahook command: ultrahook -k localhost https : //localhost.com/xxx/yyy/zzz
hook url used in stripe: http : //localhost.arivanza.ultrahook.com/xxx/yyy/zzz
I have also tried, https : //localhost.com/, but the request does not come through from the hook when tested from stripe.
LocalTunnel: I could not find the way to launch the application after downloading it from the github.
PageKite: It by default opens up localhost:80, not sure how to open up the https://localhost.com
Any help would be greatly appreciated.
Hi I have tried by self.
Please follow following steps
download ngrok and extract in any folder
run ngrok.exe and type following command ngrok http [port] -host-header="localhost:[port]"
Y0u will get a url in ngrok console "Forwording" like https://7755afd8.ngrok.io
this url is replacement of localhost:[port]
You can use no https://7755afd8.ngrok.io/index.html
Code example for stripe webhook using asp.net:
var postdata =new StreamReader(HttpContext.Request.InputStream).ReadToEnd();
var data = JObject.Parse(postdata);
var eventid = data["id"].ToString();
var eventdata = StripeHelper.GetStripeEvent(eventid);
if(eventdata!=null)
{
switch(eventdata.Type)
{
case "charge.succeeded":
//charged event
break;
case "customer.source.created":
//card added
break;
case "customer.source.deleted":
//card deleted
break;
case "customer.subscription.trial_will_end":
//trial will end
break;
}
}
If you need to receive webhooks on your local dev machine (let's say, on localhost:1234/api/url), you could use a local "mock" Stripe server, like localstripe. Once lauched, it will act like Stripe and send events if you configure it to.
Install and run localstripe:
pip3 install --user localstripe
localstripe
Configure your program to use localhost:8420 (localstripe) instead of the real Stripe (api.stripe.com). For instance with a Python program:
import stripe
stripe.api_key = 'sk_test_anythingyouwant'
stripe.api_base = 'http://localhost:8420'`
Configure localstripe to send webhook events to your program:
curl localhost:8420/_config/webhooks/mywebhook1 \
-d url=http://localhost:1234/api/url -d secret=whsec_s3cr3t
Not all events are implemented in localstripe, and it could behave slightly differently from real Stripe. But it allows you to test your application in a local sandbox, without touching actual Stripe servers.
Although the others answers work, I think they are a bit dated.
Stripe now has a CLI tool that allows you to create a connection between Stripe and your local host. Here are the steps
Create the webhook file that handles the Stripe webhook calls. Let's assume that path to this file is http://localhost/webhook.
Go to stripe.com, go to the dashboard, then click on Developers, and Webhooks, then add a new endpoint. Make sure the URL in that endpoint is the one from step 1 above (i.e., http://localhost/webhook)
Download and install the Stripe CLI locally. Then follow the instructions to login
In your Stripe CLI, run the following command:
stripe listen --forward-to http://localhost/webhooks.
This will eventually listen to Stripe for any webhooks to your local server, and forward them to your sever locally (i.e, it creates a bridge between the two)
Test your work.
The problem with the above solution is it is not going to send back the responses of the webhook back to the Stripe server (because the http://localhost/webhook is private to your network).
If you insist on having responses back to Stripe, then you should either
Map your localhost to a public domain
Use a tunnel, such as ngrok. This answer describes how to use ngrok, but for me, I make the ngrok call this way:
ngrok http -host-header=localhost 80
The above call would give me something like https://<some-random-numnber>.ngrok.io
So in stripe.com, I would have to write the endpoint as
https://<some-random-numnber>.ngrok.io/<path-to-webhook-response-page>/
Hope this helps
Although the others answers work, I think they are a bit dated.
Stripe now has a CLI tool that allows you to create a connection between Stripe and your local host. Here are the steps
Create the webhook file that handles the Stripe webhook calls. Let's
assume that path to this file is http://localhost/webhook.
Go to stripe.com, go to the dashboard, then click on Developers, and
Webhooks, then add a new endpoint. Make sure the URL in that
endpoint is the one from step 1 above (i.e.,
http://localhost/webhook)
Download and install the Stripe CLI locally. Then follow the
instructions to login
In your Stripe CLI, run the following command:
stripe listen --forward-to http://localhost/webhooks.
This will eventually listen to Stripe for any webhooks to your local
server, and forward them to your sever locally (i.e, it creates a
bridge between the two)
register url in VerifyCsrfToken[Middleware]:
class VerifyCsrfToken extends BaseVerifier
{
protected $except = [
'webhook'
];
}
Test your work

Chromecast "StartApplicationRequest failed with status: -4"

I've set up the Chromecast SDK, whitelisted my device, and am running web servers at the URLs I provided in the whitelist request.
The chromecast tic tac toe app works fine with the default app id "TicTacToe", however changing it to my own: "1813060e-33c5-41dc-b356-0d2bad12497f" or "1813060e-33c5-41dc-b356-0d2bad12497f_1" does not work.
The server url is up and running at http://chromecast.clockworkmod.com/, but no requests are being made to it by Chromecast. The chromecast doesn't display anything. However I get a few errors in the log.
Here is the logcat.
W/StartSessionTask(15590): StartApplicationRequest failed with status:
-4 E/ApplicationSession(15590): StartSessionTask failed with error: failed to start application: request failed D/GameActivity(15590):
start session failed: failed to start application: request failed
I've also tried using the internal app id with the dev url I had provided, http://192.168.1.2:3000/
I found the answer here:
unable to cast to personal whitelisted receiver app
Using the Chromecast app on my Macbook, I went into Settings.
Send serial number when Checking for updates
Reboot device the device using the Mac update app
This resolved the error for me. The chromecast doesn't know if it is whitelisted unless you send the serial during update checks.
I think I see what's missing! In your receiver you gave a link to, you have:
var receiver = new cast.receiver.Receiver(
'GoogleCastSampleApp',
[cast.receiver.RemoteMedia.NAMESPACE],
"",
5);
But it should be (fill in the 'YOUR APP ID HERE' with your App ID)
var receiver = new cast.receiver.Receiver(
'YOUR APP ID HERE',
[cast.receiver.RemoteMedia.NAMESPACE],
"",
5);
I am running into the same error as well. I after setting the Chromecast to send the serial when checking for updates I was finally able to access the debugger one port 9222. Unfortunately, I don't see anything happen on the Chromecast at all when I select it from the device list on my Nexus and try sending one of the demo videos.
Something I noticed and I don't know it makes difference or not but if you whitelist a domain in the GoogleCast extension for Chrome and you include the "http://" it will cause the injection to not work. I wonder if this is the problem with the look up that the Chromecast performs as I submitted my URLs to Google with the http:// prepended. Again I am not sure this should really make a difference but I plan on trying to resubmit the URLs just to see.
Install cURL in your windows machine from here
Now make sure that your device and laptop are in same network.
Now go to command prompt, type curl -d "" http://:8008/apps/YouTube
there If it gets casted automatically to TV then instead of YouTube put your appid and try.
If not then your router is blocking some traffic.

Resources