File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ const app = require ( 'express' ) ( )
2
+ const bodyParser = require ( 'body-parser' )
3
+
4
+ app . use ( bodyParser . json ( ) )
5
+
6
+ const onInboundCall = ( request , response ) => {
7
+ const ncco = [ {
8
+ action : 'talk' ,
9
+ text : 'Please say something' ,
10
+ } ,
11
+ {
12
+ action : 'input' ,
13
+ eventUrl : [ `${ request . protocol } ://${ request . get ( 'host' ) } /webhooks/asr` ] ,
14
+ speech : {
15
+ endOnSilence : 1 ,
16
+ language : "en-US" ,
17
+ uuid : [ request . query . uuid ]
18
+ }
19
+ }
20
+ ]
21
+ response . json ( ncco )
22
+ }
23
+
24
+ const onInput = ( request , response ) => {
25
+ const speech = request . body . speech . results [ 0 ] . text
26
+
27
+ const ncco = [ {
28
+ action : 'talk' ,
29
+ text : `You said ${ speech } `
30
+ } ]
31
+
32
+ response . json ( ncco )
33
+ }
34
+
35
+ app
36
+ . get ( '/webhooks/answer' , onInboundCall )
37
+ . post ( '/webhooks/asr' , onInput )
38
+
39
+ app . listen ( 3000 )
You can’t perform that action at this time.
0 commit comments