Users can send two types of media as messages -

  1. Only Media file

  2. Media file with a text

For the first case where the user only sends a Media File, Dialogflow receives the URL of the sent media.

For the case where the user sends Media File along with a text, the URL of the sent media is sent by adding it along with the text.

To handle URLs as user queries in Dialogflow, use RegExp (Regular Expression) type entity to capture such queries.

Example Regular Expression Entities

RegEx

Description

^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

Use this to match any url received from user.

e.g. - https://moj.app/quwuj, https://fb.com/page/2928

^https?:\/\/(www\.)?YOUR_DOMAIN\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

Use this to match url of specific domain.

e.g. -

^https?:\/\/(www\.)?fb\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

This will only match with URL with "fb" as a domain name. e.g. - https://fb.com/page/2928

RegExp to match URL of media sent by end-user

^https?:\/\/(www\.)?aisensy-project-media-library\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$

^[0-9]{10}$

Use this to capture a 10-Digit number sent by the end-user

e.g. - Capture 10 digit mobile number only


How to set up RegExp type Entity in Google Dialogflow

  1. Go to Entities & click on Create Entity

2. Give a name to your entity & check the RegExp Entity

3. Add your RegExp & click on Save

4. Next create an intent to set up the training phrase, Parameter to capture the Media URL sent by the end-user & Chatbot Response. Once done with the setup, click on Save.

5. You can verify your setup from the Console

6. As you can see we have captured the URL sent by the user in Dialogflow Parameter. You can link this with User Attributes (AiSensy Dashboard) to store it in your AiSensy Contacts Dashboard.

Did this answer your question?