drachtio / drachtio-dialogflow-phone-gateway

An open source telephony gateway for Dialogflow built using drachtio and freeswitch
MIT License
15 stars 6 forks source link

Use incomming number in Dialogflow Webhook #6

Closed raoulduivestein closed 4 years ago

raoulduivestein commented 4 years ago

Thanks for this great project! 🥇 How can I use a incomming number in a dialogflow webhook?

davehorton commented 4 years ago

You can send the incoming number to dialogflow as a parameter in the initial event if you want. Is that what you are looking to do?

raoulduivestein commented 4 years ago

Yes great! How can i do that?

davehorton commented 4 years ago

you would need to change this line:

      endpoint.api('dialogflow_start', `${endpoint.uuid} ${dfOpts.project} ${dfOpts.lang} ${welcomeEvent}`);

to something like this:

     const params = {callingNumber: this.req.callingNumber};
      endpoint.api('dialogflow_start', `${endpoint.uuid} ${dfOpts.project} ${dfOpts.lang} ${welcomeEvent} '${JSON.stringify(params)}'`);
raoulduivestein commented 4 years ago

Thanks Dave this works great!