Hi,
we have use-case where user is giving some order numbers and then making a webhook call, but getting plus & hypen symbol in the order number, how to remove those or not to add those in user utterance?
like user utterance is: 3226611004567 but getting +32-266-110-04567, need only numbers 3226611004567
Hi @mayur4,
Welcome to Google Cloud Community!
I understand that you need guidance on how to remove the plus & hypen symbol in the order number in user utterance.
Here’s how to handle this in Dialogflow CX to extract only the digits:
1. Dialogflow CX Agent Design:
Use a Parameter: Create a parameter for the order number in your intent. This parameter will capture the user’s input, including any dashes or plus signs. For example, you could name it "orderNumber".
Regular Expression: Use a regular expression to extract the digits only. In your intent, within the parameter's "Entity Type," you'll see a section for "Regular Expression." Here's a suitable expression:
\d+
This expression matches one or more digits (\d+) and will capture the entire sequence of digits from the user's input.
2. Webhook Handling:
In your webhook: You'll receive the order number as a parameter in the request payload.
Clean the Input: Before processing the order number, use your programming language's string manipulation functions to remove any non-digit characters.
For example, in Python:
order_number = request.get_json()["orderNumber"]
order_number = ''.join(filter(str.isdigit, order_number))
3. Example Dialogflow CX Intent:
{
"displayName": "OrderLookup",
"trainingPhrases": [
{
"text": "My order number is +32-266-110-04567"
},
{
"text": "I need to check on order 3226611004567"
}
],
"parameters": [
{
"name": "orderNumber",
"displayName": "Order Number",
"required": true,
"entityType": "@sys.number",
"isList": false,
"regex": "\\d+"
}
],
"webhook": {
"disabled": false,
"webhookUrl": "https://your-webhook-endpoint.com" // Replace with your actual webhook URL
}
}
Here’s a breakdown of the JSON code above:
Here’s additional key points to keep in mind:
I hope the above information is helpful.
User | Count |
---|---|
2 | |
1 | |
1 | |
1 | |
1 |