0

In Dialogflow CX, I have used phone gateway. I want extract the caller ID of the user who calls the voice bot. According to the documentation, we can get the caller id from the payload field in webhook. But I dont see a payload field or caller id in the request in webhook. How can I extract the customer phone number who calls? Thanks in advance.

To understand the problem better, here is the sample code that just prints the contents of the request:

from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/webhook', methods=['GET', 'POST'])
def webhook():
    req = request.get_json(force=True)
    print(req)
        
if __name__ == "__main__":
    app.run(host='0.0.0.0',port=5000)

The contents of the request is attached here

1 Answers1

0

You can retrieve the caller_id value from the payload field in the webhook request. Note that the webhook should be enabled as it’s required to retrieve the telephony field.

Here’s an example webhook code using Node.js to log the caller_id for Dialogflow CX Phone Gateway from your webhook request:

console.log('Caller ID' + JSON.stringify(request.body.payload.telephony));

Result:

Caller ID

Riel
  • 444
  • 2
  • 5
  • I am using Python code. When I print out the entire request, it does not contain telephony nor payload field. Do you have any idea about it? – Manasa Krishna Aug 13 '21 at 00:58
  • There seems to be an issue with retrieving the caller ID from Dialogflow CX Phone Gateway. You may check this Google Group conversation for [reference](https://groups.google.com/g/dialogflow-cx-edition-users/c/YgdRpX6qjI8). You may also consider filing this via [Issue Tracker](https://cloud.google.com/dialogflow/docs/support/getting-support#issues) for Dialogflow CX. – Riel Aug 17 '21 at 22:34