Skip to content

Commit

Permalink
fix(resources): leave resource previous method spec paramValues intact (
Browse files Browse the repository at this point in the history
#27)

* do not modify method spec paramValues
on populating URL Params

* update webhook signing examples
  • Loading branch information
lucasassisrosa authored Feb 17, 2020
1 parent decf132 commit 42a4b6d
Show file tree
Hide file tree
Showing 4 changed files with 460 additions and 6 deletions.
14 changes: 14 additions & 0 deletions examples/webhook-signing/call-control/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

const Telnyx = require('telnyx');

/**
* To run this file, just provide your Secret API Key, like so:
* TELNYX_API_KEY=KEYXXX node index.js
*/

const apiKey = process.env.TELNYX_API_KEY;

const telnyx = Telnyx(apiKey);

telnyx.calls.create({connection_id: 'uuid', to: '+1111111111111', from: '+1111111111111'});
17 changes: 14 additions & 3 deletions examples/webhook-signing/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ app.post('/webhooks', bodyParser.json(), function(req, res) {
return res.status(400).send('Webhook Error:' + e.message);
}

/**
* Messaging:
*/
if (event.data.event_type === 'message.finalized') {
console.log('Message Finalized.Status: ' + event.data.payload.call_control_id);
}

/**
* Inbound Call Control:
* first we listen for an initiation event and then answer the call
Expand All @@ -44,11 +51,15 @@ app.post('/webhooks', bodyParser.json(), function(req, res) {
console.log('Call Initiated. Answering call with call control id: ' + event.data.payload.call_control_id);

const call = new telnyx.Call({call_control_id: event.data.payload.call_control_id});
call.answer(apiKey);

call.answer();
}
if (event.data.event_type === 'call.answered') {
console.log('Call answered through webhook signing: ' + event.data.id);
console.log(event.data.payload);
console.log('Call Answered. Gather audio with the call control id: ' + event.data.payload.call_control_id);

const call = new telnyx.Call({call_control_id: event.data.payload.call_control_id});

call.gather_using_audio({audio_url: 'https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3'});
}

// Event was 'constructed', so we can respond with a 200 OK
Expand Down
Loading

0 comments on commit 42a4b6d

Please sign in to comment.